public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/55527] New: Passing structures containing floats by value in calls are underoptimized
@ 2012-11-29  4:12 alex.gaynor at gmail dot com
  2012-11-29 10:03 ` [Bug target/55527] " rguenth at gcc dot gnu.org
  2024-03-20  6:49 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: alex.gaynor at gmail dot com @ 2012-11-29  4:12 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: alex.gaynor@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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/55527] Passing structures containing floats by value in calls are underoptimized
  2012-11-29  4:12 [Bug other/55527] New: Passing structures containing floats by value in calls are underoptimized alex.gaynor at gmail dot com
@ 2012-11-29 10:03 ` rguenth at gcc dot gnu.org
  2024-03-20  6:49 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-11-29 10:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55527

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-11-29
          Component|other                       |target
     Ever Confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2012-11-29 10:03:26 UTC ---
Confirmed.  It's a mess from expansion on (assembly is better with -mtune=core2
which avoids going through the stack).  It's of course an ABI issue - I'm not
sure where to best look for opportunities to optimize this.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/55527] Passing structures containing floats by value in calls are underoptimized
  2012-11-29  4:12 [Bug other/55527] New: Passing structures containing floats by value in calls are underoptimized alex.gaynor at gmail dot com
  2012-11-29 10:03 ` [Bug target/55527] " rguenth at gcc dot gnu.org
@ 2024-03-20  6:49 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-20  6:49 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is fixed in GCC 11 at -O3 and GCC 12 at -O2:
g:
.LFB0:
        .cfi_startproc
        unpcklps        %xmm1, %xmm0
        jmp     f

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-20  6:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-29  4:12 [Bug other/55527] New: Passing structures containing floats by value in calls are underoptimized alex.gaynor at gmail dot com
2012-11-29 10:03 ` [Bug target/55527] " rguenth at gcc dot gnu.org
2024-03-20  6:49 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).