A while ago I read somewhere that SSE intrinsic functions compile into efficient machine code because compilers treat them differently from ordinary functions. I am wandering how actually compilers do it and what C programmers can do to facilitate the process. Are there any guidelines on how to use intrinsic functions in a manner that makes compiler’s job of generating efficient machine code easier.
Thanks.
The intrinsics compile down to the instructions the represent, whether this is efficient or not depends on how they are used.
also, each compiler treats intrinsics a little differently (aka its implementation specific), but GCC is open source, so you can see how they treat the SSE ones, Open Watcom*, LCC, PCC and TCC* are all open source C compilers, although thwey don’t have SSE intrinsics, they should still have intrinsics, and you can see how they handle them.
I think what you read was related to auto vectorization of code, something GCC(see this) and ICC are very good at, but they aren’t as good as hand optimized code, at least not yet
*might have been updated with support for SSE, haven’t checked lately…