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

--- Comment #7 from Bart Van Assche <bart.vanassche at gmail dot com> ---
Initializing small data structures via structure assignment is a common
approach in the Linux kernel.

This is the code gcc generates with the no-sse option applied:

(gdb) disas bio_init3
Dump of assembler code for function bio_init3:
   0x00000000004011b0 <+0>:     mov    %rdi,%r8
   0x00000000004011b3 <+3>:     mov    $0xf,%ecx
   0x00000000004011b8 <+8>:     xor    %eax,%eax
   0x00000000004011ba <+10>:    rep stos %rax,%es:(%rdi)
   0x00000000004011bd <+13>:    movl   $0x1,0x20(%r8)
   0x00000000004011c5 <+21>:    mov    %dx,0x62(%r8)
   0x00000000004011ca <+26>:    movl   $0x1,0x64(%r8)
   0x00000000004011d2 <+34>:    mov    %rsi,0x68(%r8)
   0x00000000004011d6 <+38>:    ret    

This is the code clang generates with the no-sse option applied:

(gdb) disas bio_init3
Dump of assembler code for function bio_init3:
   0x00000000004012c0 <+0>:     movq   $0x0,0x18(%rdi)
   0x00000000004012c8 <+8>:     movq   $0x0,0x10(%rdi)
   0x00000000004012d0 <+16>:    movq   $0x0,0x8(%rdi)
   0x00000000004012d8 <+24>:    movq   $0x0,(%rdi)
   0x00000000004012df <+31>:    movl   $0x1,0x20(%rdi)
   0x00000000004012e6 <+38>:    movq   $0x0,0x24(%rdi)
   0x00000000004012ee <+46>:    movq   $0x0,0x2c(%rdi)
   0x00000000004012f6 <+54>:    movq   $0x0,0x34(%rdi)
   0x00000000004012fe <+62>:    movq   $0x0,0x3c(%rdi)
   0x0000000000401306 <+70>:    movq   $0x0,0x44(%rdi)
   0x000000000040130e <+78>:    movq   $0x0,0x4c(%rdi)
   0x0000000000401316 <+86>:    movq   $0x0,0x54(%rdi)
   0x000000000040131e <+94>:    movq   $0x0,0x5a(%rdi)
   0x0000000000401326 <+102>:   mov    %dx,0x62(%rdi)
   0x000000000040132a <+106>:   movl   $0x1,0x64(%rdi)
   0x0000000000401331 <+113>:   mov    %rsi,0x68(%rdi)
   0x0000000000401335 <+117>:   movq   $0x0,0x70(%rdi)
   0x000000000040133d <+125>:   ret    

Is there any x86_64 CPU on which the latter code runs slower than the former?

Reply via email to