From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3B3863857C52; Thu, 21 Oct 2021 14:09:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B3863857C52 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102879] [12 Regression] Dead Code Elimination Regression at -O3 Date: Thu, 21 Oct 2021 14:09:40 +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: 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, 21 Oct 2021 14:09:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102879 Aldy Hernandez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com --- Comment #1 from Aldy Hernandez --- We should've elided the call to foo() in the 8->3 edge. This is the IL in vrp-thread1 dump: int main () { int h; int g; int _3; _Bool _5; int _6; char iftmp.4_11; int _12; int _19; int _21; char iftmp.4_22; int d.0_25; _Bool _26; int _27; int c.2_28; char _29; int _30; int _42; char iftmp.4_43; int _48; int _50; _Bool _53; int _56; int _59; char iftmp.4_60; int _62; [local count: 134197598]: c =3D 2; goto ; [100.00%] [local count: 88583700]: foo (); [local count: 268435457]: g_18 =3D g_10 + 1; [local count: 402633054]: # g_10 =3D PHI <0(2), g_18(4)> if (g_10 !=3D 2) goto ; [66.67%] else goto ; [33.33%] [local count: 268435456]: d.0_25 =3D d; _26 =3D d.0_25 =3D=3D 0; _27 =3D (int) _26; c.2_28 =3D c; _29 =3D (char) c.2_28; _30 =3D (int) _29; if (_29 >=3D 0) goto ; [59.00%] else goto ; [41.00%] [local count: 110058536]: # iftmp.4_11 =3D PHI <_29(6)> _12 =3D (int) iftmp.4_11; d =3D _12; _48 =3D (int) _29; d =3D _48; _19 =3D (int) _29; d =3D _19; goto ; [100.00%] [local count: 158376920]: _42 =3D _30 >> _27; iftmp.4_43 =3D (char) _42; _50 =3D _42; d =3D _50; _53 =3D _50 =3D=3D 0; _56 =3D (int) _53; _21 =3D _30 >> _56; iftmp.4_22 =3D (char) _21; _3 =3D _21; d =3D _3; _5 =3D _3 =3D=3D 0; _6 =3D (int) _5; _59 =3D _30 >> _6; iftmp.4_60 =3D (char) _59; _62 =3D _59; d =3D _62; if (_62 =3D=3D 0) goto ; [66.33%] else goto ; [33.67%] [local count: 134197598]: return 0; } So, presumably _62 =3D=3D 0 cannot be true. If _62 =3D=3D 0, then 0 =3D _30 >> _6; But that cannot happen because _30 is 2 if you follow the series of copies = from the "c" global. There is no way 0 =3D 2 >> x can ever be true. There's probably a couple things missing here. Maybe operator_rshift::op1_range needs to be taught that ~[0,0] =3D x >> y implie= s x is non-zero. But also, we can't see through the load from the c=3D2 global.=20 Shouldn't that c=3D2 have been propagated by someone at this point? (VRP1?= )=