[llvm-bugs] [Bug 35134] New: GCC does a better job with returning large structs
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 30 11:57:57 PDT 2017
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: unassignedbugs at nondot.org
Reporter: jmuizelaar at mozilla.com
CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171030/e322bc00/attachment.html>
More information about the llvm-bugs
mailing list