Reputation: 63710
I've done some inline ASM coding for SSE before and it was not too hard even for someone who doesn't know ASM. But I note MS also provide intrinsics wrapping many such special instructions.
Is there a particular performance difference, or any other strong reason why one should be used above the other?
To repeat from the title, this is specifically covering intrinsics exposed by VC++ 2008 for unmanaged, native C++.
Upvotes: 4
Views: 2373
Reputation: 15725
Use intrinsics.
Using assembly will usually result in several days of non-stop work, only to find out the compiler beats your best performance by 5%. (5% if you're really good; most likely 30%.)
Upvotes: 0
Reputation: 212929
In general it's better to use intrinsics - it's more productive for the programmer and a good compiler (e.g. Intel ICC) will do a decent job of register allocation, instruction scheduling etc. The Microsoft compiler is not as good in this respect but it probably still does a reasonable job - you can always switch to ICC later if you need to get better performance.
Upvotes: 3
Reputation: 74654
Intrinsics are identical to their equivalent assembly instructions and you should use them if possible - the compiler knows to directly translate them, there is no performance difference.
Upvotes: 1
Reputation: 55395
There is no inline assembly in Visual C++ for x64. Intrinsics can be used on x64 as well. If you ever want to port your code to x64, you'll have to use intrinsics.
Upvotes: 4