Question

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++.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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%.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top