From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E1CE83858D37; Fri, 28 Apr 2023 11:46:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E1CE83858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682682371; bh=sn0uomX/xH4UhamGtVeNEi5spDCpK7M3gU439RiB9Yo=; h=From:To:Subject:Date:From; b=VAjTapNoAOfDR5YIloCvXYGiPMLQNxXjcxvM2+ML7xd62Y2amfVUMWRPTX15aJhZK CeSZYE5zO8LuykyRxDiTHa3Y2PP0hOlMvILj3PhOAuTcDEAVaFt28ZQLW0pqC8pZzG UgOra8bJfMCqNCyErQNHxFhW6EK3StFD/X3VE3Hk= From: "chfast at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109667] New: [12/13/14 Regression] Unnecessary temporary storage used for 32-byte struct Date: Fri, 28 Apr 2023 11:46:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: chfast at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109667 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 =3D {}; for (int i =3D 0; i < 1; ++i)=20 r.v[i] =3D z; *v =3D 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=