From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 025FF39B2435; Thu, 24 Jun 2021 18:30:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 025FF39B2435 From: "amacleod at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101186] predictable comparison of integer variables not folded Date: Thu, 24 Jun 2021 18:30:42 +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: enhancement 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: 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, 24 Jun 2021 18:30:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101186 Andrew Macleod changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at redhat dot com, | |amacleod at redhat dot com --- Comment #3 from Andrew Macleod --- (In reply to Di Zhao from comment #0) > GCC fail to remove dead codes for following cases: >=20 > #include >=20 > void f (unsigned int a, unsigned int b, unsigned int c) > // if a,b,c are signed, VRP can remove dead code > { > if (a =3D=3D b) > { > printf ("a"); > if (c < a) > { > printf ("b"); > if (c >=3D b) > printf ("Unreachable!"); > } > } > } >=20 I believe this commit fixes the first case, EVRP now eliminates the unreach= able print. commit ce0b409f562cd09c67cc2dce74143a0f0647cde5 (origin/master, origin/HEAD) Author: Andrew MacLeod Date: Thu Jun 24 11:13:47 2021 -0400 Fix relation query of equivalences. the second one requires some form of predication, or the desire to thread t= hru the top of the block.. It touches on some stuff Aldy is looking at (which i= sn't finished yet) . : if (a_7(D) !=3D 0) goto ; [INV] else goto ; [INV] : goto ; [INV] : # c_16 =3D PHI : # b_1 =3D PHI if (b_1 <=3D 999) goto ; [INV] else goto ; [INV] : if (a_7(D) !=3D 0) goto ; [INV] else goto ; [INV] : if (x_10(D) < c_16) goto ; [INV] else goto ; [INV] I dont know what rules there are, but the path 2->3->9->10->4 would resul= t in bb4 becoming "goto bb5", and then BB5 could fold to "goto bb8" as c_16 =3D= =3D x_10 on that path in BB9.=