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

            Bug ID: 120588
           Summary: [14/15/16 regression] poor code when returning struct
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ell_se at yahoo dot com
  Target Milestone: ---

The following code:

    struct X {
        int i;
        long l;
    };

    struct X f (struct X x) {
        return x;
    }

Compiled with -O2 on x86-64:

    f:
            mov     rax, rsi
            mov     rsi, rdi
            push    rbp
            pop     rbp
            mov     rdi, rax
            mov     rax, rsi
            mov     rdx, rdi
            ret

Testing on godbolt, this started with GCC 14.1 and up to trunk. GCC 13.3
produces the expected:

    f:
            mov     rdx, rsi
            mov     eax, edi
            ret

Other variants of this also produce worse code than 13.3, but that's the most
obvious example.

Reply via email to