From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 85A303858C30; Fri, 13 Oct 2023 06:43:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85A303858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697179384; bh=VfFYZS7+7lQdrztKKlxmVgWzu9eVZhgPiKFR4PWN0EY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xudZw+nWItLDxPG02+ujcLrPnL/+AZ+PaT3tXqxBQ+n+UtoCRqXCwxO8HIut8nx0S o+M9cSiTet4SOutXTTNU/OEgpLVYPNyrl80UVtFG9+isppikVs+bd1tVW56tRphG2V 9Bw5lU0kNbjt1uiNrt2Jy7lexmK0hdAhYGw//yVg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/111773] Inconsistent optimization of replaced operator new() Date: Fri, 13 Oct 2023 06:43:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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_status everconfirmed assigned_to 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111773 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |UNCONFIRMED Ever confirmed|1 |0 Assignee|rguenth at gcc dot gnu.org |unassigned at gcc d= ot gnu.org --- Comment #5 from Richard Biener --- So the second example is fixed, but it's quite a corner-case so probably not worth backporting. Given we have a single bugreport for two issues back to UNCONFIRMED for the first issue. I agree with Andrew _that_ issue behaves within the constraints of the standard. ISTR it says that 'operator new' has to return a pointer that nothing else points to which means it acts as if it were restrict qualified. That allows GCC to conclude x !=3D 0 because it rewrites x =3D=3D 0 as a - p =3D=3D 0 a= nd a =3D=3D p. The difference operation cannot be constant folded based on th= is but during IPA optimization we inline 'new' which exposes p =3D=3D a and th= us a - p =3D=3D 0.=