From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0C1623858029; Wed, 12 Jan 2022 00:39:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C1623858029 From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99755] failure to fold a conditional that's a subset of another expression Date: Wed, 12 Jan 2022 00:39:06 +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: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: amacleod at redhat dot com 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: --- 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, 12 Jan 2022 00:39:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99755 --- Comment #3 from Andrew Macleod --- we now know the PHI is an equivalence when the other argument is UNDEFINED.: [local count: 268435456]: x_12 =3D i_8(D) + 1; x_12 : int [3, +INF] Equivalence set : [x_7, x_12] <<--Equivalence marked=20=20=20 [local count: 805306367]: # x_7 =3D PHI _4 =3D i_8(D) =3D=3D 2; _5 =3D j_9(D) =3D=3D 3; _15 =3D k_11(D) =3D=3D 4; _21 =3D _5 & _15; _16 =3D _4 & _21; _17 =3D x_7 !=3D 3; _18 =3D _16 & _17; if (_18 !=3D 0) goto ; [0.00%] else goto ; [100.00%] x_7 : int [3, +INF] 5->6 (T) _4 : _Bool [1, 1] 5->6 (T) _5 : _Bool [1, 1] 5->6 (T) x_7 : int [4, +INF] 5->6 (T) i_8(D) : int [2, 2] 5->6 (T) j_9(D) : int [3, 3] Whats missing is potentially recalculating equivalences on outgoing edges. we know=20 1) i_8 has a range of [2,2] on the edge 5->6 2) we know that x_7 and x_12 are equivalences 3) we know that x_12 =3D i_8(D) + 1; 4) We have the ability to recompute x_12 using i_8 on that edge, which wo= uld=20 conclude x_12 =3D [3,3] on that edge. We just don't know to ask that quest= ion (yet). 5) the equivalence set of x_12=3D[3, 3] and x_7=3D[4, +INF] are incompati= ble. their intersection is EMPTY, which in turns means the edge is unexecutable. This is demonstrated by the requirement that x_7 !=3D 3 be true, as well as= (x_7 =3D=3D x_12 =3D=3D [3,3]) at the same time. The information is all there, we just need to figure out how best to use it= .=