[Bug middle-end/70308] memset generates rep stosl instead of rep stosq
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 22 11:39:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70308
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Uroš Bizjak from comment #3)
> Minimized testcase:
>
> --cut here--
> extern int scanf (const char *, ...);
> extern void *memset (void *, int, __SIZE_TYPE__);
>
> int
> main () {
> char buf[128];
>
> if (scanf("%s", buf) != 1)
> return 42;
>
> memset(buf,0, 128);
> asm volatile("": : :"memory");
> return 0;
> }
> --cut here--
>
> gcc -O3, generic tuning (-mtune=x86-64):
>
> .L7:
> xorl %eax, %eax
> movq %rsp, %rdi
> movl $32, %ecx
> rep; stosl
> xorl %edx, %edx
> jmp .L1
>
> Changing the name of "main" to e.g "foo":
>
> .L7:
> xorl %eax, %eax
> movq %rsp, %rdi
> movl $16, %ecx
> rep; stosq
> xorl %edx, %edx
> jmp .L1
>
> Interesting...
That's probably because for main() we can predict the call to be cold
(main is called exactly once).
More information about the Gcc-bugs
mailing list