From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AED9B3858C60; Thu, 21 Oct 2021 08:25:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AED9B3858C60 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level Date: Thu, 21 Oct 2021 08:25:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization, TREE X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 08:25:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102872 Bug ID: 102872 Summary: If statement is always false but not figured out at gimple level Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization, TREE Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: void foo(void); static int a, b; int main() { for (; a; ++a) { unsigned short d =3D a; if (!(b | d) && d) foo(); } } ---- CUT --- This is the reduced testcase of PR 102703 but without the store to a static variable which then was removed. In VRP1 we have: d_10 =3D (short unsigned int) a.3_5; _9 =3D a.3_5 & 65535; if (_9 =3D=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 477815112]: if (d_10 !=3D 0) goto ; [33.00%] else goto ; [67.00%] [local count: 157678986]: foo (); _9 and d_10 have the same value though different types.=