From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED1A33857C66; Wed, 19 Jan 2022 16:40:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED1A33857C66 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103721] [12 regression] wrong code generated for loop with conditional since r12-4790-g4b3a325f07acebf4 Date: Wed, 19 Jan 2022 16:40:28 +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: wrong-code 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: 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: Wed, 19 Jan 2022 16:40:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103721 --- Comment #7 from Aldy Hernandez --- After chatting with Andrew about this, it seems the problem is we are start= ing a path mid-loop and crossing a backedge. This causes us to use relations we had on one iteration in another iteration. [local count: 955630225]: # searchVolume_11 =3D PHI <1(4), 0(3)> # currentVolume_8 =3D PHI # **BACKEDGE** [local count: 1073741824]: # searchVolume_5 =3D PHI # currentVolume_6 =3D PHI _2 =3D searchVolume_5 !=3D currentVolume_6; _3 =3D searchVolume_5 !=3D 0; _4 =3D _2 & _3; if (_4 !=3D 0) goto ; [89.00%] else goto ; [11.00%] ... ... The _8 =3D=3D _5 relation in BB8 is using _5 from a previous iteration (tha= t came through BB9). Basically 8->9 has a use before def of _5. Once we hit a back edge, we should probably kill all current relations and disable looking outside the path altogether for relations. I will experiment.=