From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6650E3856DD3; Fri, 29 Jul 2022 16:29:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6650E3856DD3 From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106474] DCE depends on how if expressions are nested Date: Fri, 29 Jul 2022 16:29:54 +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.1.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: Fri, 29 Jul 2022 16:29:54 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106474 --- Comment #2 from Andrew Macleod --- (In reply to Richard Biener from comment #1) > For the failing case we see >=20 > : > if (c_5(D) =3D=3D s_6(D)) > goto ; [INV] > else > goto ; [INV] >=20 > : > if (c_5(D) !=3D 0) > goto ; [INV] > else > goto ; [INV] >=20 > : > if (s_6(D) !=3D 0) > goto ; [INV] > else > goto ; [INV] >=20 > and we basically fail to thread 2->3->4->6, eliminating the if (s_6(D) != =3D 0) > branch when c_5(D) =3D=3D s_6(D) and c_5(D) =3D=3D 0. >=20 > It looks like relations / equivalences related, but maybe not exactly.=20 > Andrew? it is related. Due to the expense, we don't evaluate every equivalence at every use point. In this case, there was no obvious "trigger" when we see = s_6 !=3D 0 to go query all of the equivalences to see if they have ranges. However range_from_dom () is now quite efficient and has a "read-only" mode where it will make a DOM query without filling the cache. I am experimenting with having the on-entry cache fill also invoke range_from_dom on equivalen= ces in read-only mode to see if any existing equivalence value can improve the range. The initial protoype reduces that test case in EVRP from : _1 =3D ~c_7(D); _2 =3D (int) _1; _3 =3D ~s_8(D); _4 =3D (int) _3; if (c_7(D) =3D=3D s_8(D)) goto ; [INV] else goto ; [INV] : if (c_7(D) !=3D 0) goto ; [INV] else goto ; [INV] : if (s_8(D) !=3D 0) goto ; [INV] else goto ; [INV] : DCEMarker0_ (); : return; to : _1 =3D ~c_7(D); _2 =3D (int) _1; _3 =3D ~s_8(D); _4 =3D (int) _3; return; Let me run some performance numbers and see what the result is to see if th= ere is any throtteling needed or not.=