public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/115576] New: [14 regression] Worse code generated for simple struct conversion
@ 2024-06-21  7:44 jzwinck at gmail dot com
  2024-06-21  7:49 ` [Bug c++/115576] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jzwinck at gmail dot com @ 2024-06-21  7:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115576
           Summary: [14 regression] Worse code generated for simple struct
                    conversion
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jzwinck at gmail dot com
  Target Milestone: ---

Here is some simple code from a real application which converts one struct to a
similar but larger one:

    #include <cstdint>

    struct S64
    {
        uint64_t a;
        int8_t b;
        int8_t c;
        uint16_t d;
    };

    struct S32
    {
        uint32_t a;
        int8_t b;
        int8_t c;
        uint16_t d;

        S64 To64() const;
    };

    S64 S32::To64() const
    {
        return S64{a, b, c, d};
    }

GCC 13 and earlier emitted good code for this (as does Clang):

    S32::To64() const:
        mov     eax, DWORD PTR [rdi]
        mov     edx, DWORD PTR [rdi+4]
        ret

GCC 14 is much worse:

    S32::To64() const:
        xor     edx, edx
        mov     esi, DWORD PTR [rdi+4]
        mov     eax, DWORD PTR [rdi]
        movabs  rdi, -4294967296
        mov     rcx, rdx
        and     rcx, rdi
        or      rcx, rsi
        mov     rdx, rcx
        ret

Demo: https://godbolt.org/z/YbenMeEPq

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

end of thread, other threads:[~2024-08-01  9:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21  7:44 [Bug rtl-optimization/115576] New: [14 regression] Worse code generated for simple struct conversion jzwinck at gmail dot com
2024-06-21  7:49 ` [Bug c++/115576] " pinskia at gcc dot gnu.org
2024-06-21  7:52 ` [Bug c++/115576] [14/15 " rguenth at gcc dot gnu.org
2024-06-21 17:44 ` [Bug target/115576] " pinskia at gcc dot gnu.org
2024-06-25  8:17 ` user202729 at protonmail dot com
2024-06-26  7:10 ` [Bug target/115576] [14/15 regression] Worse code generated for simple struct conversion since r14-2386-gbdf2737cda53a8 user202729 at protonmail dot com
2024-07-31 15:54 ` jakub at gcc dot gnu.org
2024-08-01  9:41 ` jakub 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).