[Bug target/70308] memset generates rep stosl instead of rep stosq

ubizjak at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Mar 22 10:04:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70308

Uroš Bizjak <ubizjak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-03-22
          Component|c                           |target
     Ever confirmed|0                           |1

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
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...


More information about the Gcc-bugs mailing list