From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 24DCF3852740; Tue, 14 Jun 2022 11:50:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24DCF3852740 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105832] [13 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 12.1.0) Date: Tue, 14 Jun 2022 11:50:51 +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: 13.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: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status 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 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: Tue, 14 Jun 2022 11:50:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105832 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW Assignee|rguenth at gcc dot gnu.org |unassigned at gcc d= ot gnu.org --- Comment #3 from Richard Biener --- So the difference boils down to GCC 12 ending up with if (iftmp.0_9 =3D=3D 1) { if (iftmp.1_10 !=3D 0) { loop with call to foo (); } } while the new unswitching code swaps these and ends up with if (iftmp.1_10 !=3D 0) { if (iftmp.0_9 =3D=3D 1) { loop with call to foo (); } } the old code also created one pointless unreachable loop copy. GCC 12 manages to elide the loop calling foo() in thread2 after fre5. There's nothing wrong with unswitching here I think - we're at most unlucky with the order of unswitchings (but that might change from current 'random' to a cost based order).=