https://bugs.llvm.org/show_bug.cgi?id=35134

            Bug ID: 35134
           Summary: GCC does a better job with returning large structs
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: jmuizel...@mozilla.com
                CC: llvm-bugs@lists.llvm.org

struct Foo {
   int o[200];
};

struct Bar {
        char p;
        Foo f;
};

__attribute__((noinline))
Foo moo()
{
        return {0};
}

void goo(Bar *f)
{
        f->f = moo();
}

with  -O3 -fno-exceptions -fomit-frame-pointer gives:

moo(): # @moo()
  push rbx
  mov rbx, rdi
  xor esi, esi
  mov edx, 800
  call memset
  mov rax, rbx
  pop rbx
  ret
goo(Bar*): # @goo(Bar*)
  push r14
  push rbx
  sub rsp, 808
  mov rbx, rdi
  lea r14, [rsp + 8]
  mov rdi, r14
  call moo()
  add rbx, 4
  mov edx, 800
  mov rdi, rbx
  mov rsi, r14
  call memcpy
  add rsp, 808
  pop rbx
  pop r14
  ret

in clang vs gcc's:

moo():
  mov rdx, rdi
  mov QWORD PTR [rdi], 0
  mov QWORD PTR [rdi+792], 0
  lea rdi, [rdi+8]
  mov rcx, rdx
  xor eax, eax
  and rdi, -8
  sub rcx, rdi
  add ecx, 800
  shr ecx, 3
  rep stosq
  mov rax, rdx
  ret
goo(Bar*):
  add rdi, 4
  call moo()
  rep ret

Notice the elided memcpy in goo()

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to