From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B56B386F0C6; Mon, 27 Jun 2022 06:45:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B56B386F0C6 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94026] combine missed opportunity to simplify comparisons with zero Date: Mon, 27 Jun 2022 06:45:48 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: cvs-commit 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: 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: Mon, 27 Jun 2022 06:45:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94026 --- Comment #12 from CVS Commits --- The master branch has been updated by Roger Sayle : https://gcc.gnu.org/g:f3f73e86ec8613f176db3e52bbfbfbb9636cb714 commit r13-1281-gf3f73e86ec8613f176db3e52bbfbfbb9636cb714 Author: Roger Sayle Date: Mon Jun 27 07:44:49 2022 +0100 [PATCH] PR tree-optimization/94026: Simplify (X>>8)&6 !=3D 0 as X&1536 = !=3D 0. This patch implements the missed optimization described in PR 94026, where a the shift can be eliminated from the sequence of a shift, followed by a bit-wise AND followed by an equality/inequality test. Specifically, ((X << C1) & C2) cmp C3 into (X & (C2 >> C1)) cmp (C3 >> = C1) and likewise ((X >> C1) & C2) cmp C3 into (X & (C2 << C1)) cmp (C3 << C= 1) where cmp is =3D=3D or !=3D, and C1, C2 and C3 are integer constants. The example in the subject line is taken from the hot function self_atari from the Go program Leela (in SPEC CPU 2017). 2022-06-27 Roger Sayle gcc/ChangeLog PR tree-optimization/94026 * match.pd (((X << C1) & C2) eq/ne C3): New simplification. (((X >> C1) & C2) eq/ne C3): Likewise. gcc/testsuite/ChangeLog PR tree-optimization/94026 * gcc.dg/pr94026.c: New test case.=