http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55527
Bug #: 55527 Summary: Passing structures containing floats by value in calls are underoptimized Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassig...@gcc.gnu.org ReportedBy: alex.gay...@gmail.com This can be reproduced with the following code: agaynor@tannit:~$ gcc --version gcc (Ubuntu/Linaro 4.7.2-4precise1) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. agaynor@tannit:~$ cat t.c struct x { float a; float b; }; void f(struct x); void g(float x, float y) { struct x z = {x, y}; f(z); } agaynor@tannit:~$ gcc -O3 -S t.c agaynor@tannit:~$ cat t.s .file "t.c" .text .p2align 4,,15 .globl g .type g, @function g: .LFB0: .cfi_startproc subq $24, %rsp .cfi_def_cfa_offset 32 movss %xmm0, 12(%rsp) movq %xmm1, (%rsp) movq (%rsp), %rdx movl 12(%rsp), %eax salq $32, %rdx movl %eax, %eax orq %rdx, %rax movq %rax, (%rsp) movq (%rsp), %xmm0 call f addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size g, .-g .ident "GCC: (Ubuntu/Linaro 4.7.2-4precise1) 4.7.2" .section .note.GNU-stack,"",@progbits It would be more efficient to compile this using the PUNPCKLD instruction, rather than all these moves and conversions from XMM to GPR registers.