Jose Catena wrote:
--> 4) The fact that if the loop is what you're truly worried about, you can optimize it by hand with __builtinia32_rep_movsd (and MSVC has a similar intrinsic), and still keep the rest of the function portable C.
<-- It is not necessary to use to use a built in function like you mention, because any optimizing compiler will use rep movsd anyway, with better register allocation if any different. If inline asm is used instead, optimizations for the whole function are disabled, as the compiler does not analyze what's done in inline assembly.
- A builtin / intrinsic != inline asm - Using inline asm doesn't disable the optimization of the function, at least not for gcc, of cause the compiler cannot optimize what's inside the asm, but how would you want to optimize "rep stosd" anyway? - As I already stated: none of the compilers I tested was able to generate a rep stosd from either a loop or memset.even at maximum optimization. So either I did something wrong in all cases or the above statement about "any optimizing compiler" is simply not true.
Regards, Timo