From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7DC423858D3C; Mon, 14 Feb 2022 18:25:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DC423858D3C From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104529] [missed optimization] inefficient codegen around new/delete Date: Mon, 14 Feb 2022 18:25:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tnfchris at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE 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: Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Feb 2022 18:25:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104529 --- Comment #2 from Tamar Christina --- I don't quite see how this is a CSE problem, There's only one of each constant and none of them are needed before the ca= ll. unlike in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D86892 You don't need the values of your array until you allocate memory for said array. x86 has the following sequence in GIMPLE _32 =3D operator new (6); MEM [(char * {ref-all})_32] =3D 255; MEM [(char * {ref-all})_32 + 4B] =3D 0; operator delete (_32, 6); which is optimal, you create the object, store the values, and remove it. AArch64 however has this MEM [(unsigned char *)&D.24688] =3D 255; MEM [(unsigned char *)&D.24688 + 4B] =3D 0; _34 =3D operator new (6); MEM [(char * {ref-all})_34] =3D MEM [(char * {ref-all})&D.24688]; D.24688 =3D{v} {CLOBBER(eol)}; operator delete (_34, 6); which is where the issue comes from. So this has nothing to do with CSE as = far as I can tell. The GIMPLE is just suboptimal.=