开发者

Intrinsics Vs inline ASM for SSE coding in VC++ 2K8

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


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜