3 ms·
Actually I have to update my own comment here, due to a completely unexpected circumstance. I just happened to diassemble some 64-bit test code I wrote tonight
by a1k0n 15y ago
Actually I have to update my own comment here, due to a completely unexpected circumstance. I just happened to diassemble some 64-bit test code I wrote tonight (unrelated to testing out the string instruction theory) and lo and behold, Apple gcc-4.2.1 with -O3 turned memset(x, 0, 7*sizeof(uint64_t)) into a 3-byte "rep stos" instruction:
0x0000000100000cee <main+30>: cld
0x0000000100000cef <main+31>: mov $0x7,%ecx
0x0000000100000cf4 <main+36>: xor %eax,%eax
0x0000000100000cf6 <main+38>: mov %r15,%rdi
0x0000000100000cf9 <main+41>: rep stos %rax,%es:(%rdi)
0x0000000100000cfc <main+44>: ...
It even does pretty much the same thing with -m32 and with optimization turned down to -O1. So perhaps things have changed.