public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109667] New: [12/13/14 Regression] Unnecessary temporary storage used for 32-byte struct
@ 2023-04-28 11:46 chfast at gmail dot com
  2023-04-28 12:27 ` [Bug tree-optimization/109667] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: chfast at gmail dot com @ 2023-04-28 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109667
           Summary: [12/13/14 Regression] Unnecessary temporary storage
                    used for 32-byte struct
           Product: gcc
           Version: 12.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chfast at gmail dot com
  Target Milestone: ---

Reduced reproducer:

struct i256 {
    long v[4];
};
void assign(struct i256 *v, long z) {
    struct i256 r = {};
    for (int i = 0; i < 1; ++i) 
        r.v[i] = z;
    *v = r;
}

https://godbolt.org/z/avM74o3r6

The compiler allocates temporary storage on stack for `r`:

assign:
        pxor    xmm0, xmm0
        mov     QWORD PTR [rsp-40], rsi
        movups  XMMWORD PTR [rsp-32], xmm0
        movdqa  xmm1, XMMWORD PTR [rsp-40]
        mov     QWORD PTR [rsp-16], 0
        movdqa  xmm2, XMMWORD PTR [rsp-24]
        movups  XMMWORD PTR [rdi], xmm1
        movups  XMMWORD PTR [rdi+16], xmm2
        ret

Regression since 12. The 11 compiles nicely to:

assign:
        mov     QWORD PTR [rdi], rsi
        mov     QWORD PTR [rdi+8], 0
        mov     QWORD PTR [rdi+16], 0
        mov     QWORD PTR [rdi+24], 0
        ret

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

end of thread, other threads:[~2023-05-08 12:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-28 11:46 [Bug tree-optimization/109667] New: [12/13/14 Regression] Unnecessary temporary storage used for 32-byte struct chfast at gmail dot com
2023-04-28 12:27 ` [Bug tree-optimization/109667] " rguenth at gcc dot gnu.org
2023-05-02  9:45 ` jakub at gcc dot gnu.org
2023-05-02  9:56 ` jakub at gcc dot gnu.org
2023-05-08 12:27 ` rguenth 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).