From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DA4E43858C60; Thu, 3 Mar 2022 11:36:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA4E43858C60 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104639] [12 Regression] Useless loop not fully optimized anymore Date: Thu, 03 Mar 2022 11:36:59 +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: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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, 03 Mar 2022 11:37:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104639 Aldy Hernandez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com --- Comment #7 from Aldy Hernandez --- FWIW, thread2 does thread everything that is threadable. That is, we thread 5->3->4 from this: [local count: 1073741824]: # i_1 =3D PHI if (i_1 =3D=3D 4) goto ; [89.00%] else goto ; [11.00%] [local count: 955630224]: goto ; [100.00%] into this: [local count: 118111600]: if (i_2(D) =3D=3D 4) goto ; [97.00%] else goto ; [3.00%] [local count: 955630224]: # i_5 =3D PHI <6(2)> [local count: 118111600]: # i_6 =3D PHI _3 =3D i_6 !=3D 0; return _3; There are no more conditionals we can thread in the final form above. To my untrained eye, it does seem like phiopt should be able to optimize: [local count: 118111600]: # i_6 =3D PHI _3 =3D i_6 !=3D 0; into: _3 =3D i_2 !=3D 0; Then BB2 and BB3 can just be cleaned up as dead?=