From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0149F3857814; Thu, 20 Jan 2022 09:44:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0149F3857814 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102540] [12 Regression] Dead Code Elimination Regression at -O3 since r12-476-gd846f225c25c5885 Date: Thu, 20 Jan 2022 09:44:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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: Thu, 20 Jan 2022 09:44:28 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102540 --- Comment #9 from Richard Biener --- I think the GCC 12 IL would require tracking equivalences on parts of registers, in this case that _2 is equal to the low part of a.0_1. That is, one would need to extend what CCP does with bit propagation to include equivalences. There's also the if ((long)unsigned-var !=3D 0) -> if (unsigned-var !=3D 0) transform that could save us here but we have that guarded with single_use () and the converted value is used after the branching but not the source so we'd have increased register pressure. I do not see a good way to fix this issue, slightly altering the testcase to do the undesired transform on the source level static long a; static unsigned b; void foo(void); int main() { long c, e; b =3D a; c =3D (unsigned)a; e =3D c ? 2 / (c + 1) : 0; if (e && !b) foo(); a =3D 0; } causes the issue to appear also with GCC 11.=