http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54315
Bug #: 54315 Summary: Unnecessary copy of return value Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassig...@gcc.gnu.org ReportedBy: hjl.to...@gmail.com CC: areg.melikadam...@gmail.com, ubiz...@gmail.com On Linux/x86-64, I got [hjl@gnu-6 pr20020]$ cat x.i union S160 { long double a; }; extern union S160 check160 (void); extern void checkx160 (union S160); void test160 (void) { checkx160 (check160 ()); } [hjl@gnu-6 pr20020]$ gcc -S -O2 x.i [hjl@gnu-6 pr20020]$ cat x.s .file "x.i" .text .p2align 4,,15 .globl test160 .type test160, @function test160: .LFB0: .cfi_startproc subq $72, %rsp .cfi_def_cfa_offset 80 call check160 fstpt 16(%rsp) movq 16(%rsp), %rdx movq 24(%rsp), %rax movq %rdx, 32(%rsp) movq %rax, 40(%rsp) movq %rdx, (%rsp) movq %rax, 8(%rsp) call checkx160 addq $72, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size test160, .-test160 .ident "GCC: (GNU) 4.7.1 20120629 (Red Hat 4.7.1-1)" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 pr20020]$ cat y.i struct S160 { long double a; }; extern struct S160 check160 (void); extern void checkx160 (struct S160); void test160 (void) { checkx160 (check160 ()); } [hjl@gnu-6 pr20020]$ gcc -S -O2 y.i [hjl@gnu-6 pr20020]$ cat y.s .file "y.i" .text .p2align 4,,15 .globl test160 .type test160, @function test160: .LFB0: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 call check160 fstpt (%rsp) call checkx160 addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size test160, .-test160 .ident "GCC: (GNU) 4.7.1 20120629 (Red Hat 4.7.1-1)" .section .note.GNU-stack,"",@progbits [hjl@gnu-6 pr20020]$ union causes unnecessary copy of return value. I don't believe ABI calls for it.