From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 831ED396EC75; Wed, 20 Jan 2021 15:32:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 831ED396EC75 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96674] Failure to optimize combination of comparisons to dec+compare Date: Wed, 20 Jan 2021 15:32:22 +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: 11.0 X-Bugzilla-Keywords: easyhack, 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: Wed, 20 Jan 2021 15:32:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96674 --- Comment #10 from CVS Commits --- The master branch has been updated by Richard Biener : https://gcc.gnu.org/g:49e8c14ef6f1f968602a04c8499a672182590e87 commit r11-6817-g49e8c14ef6f1f968602a04c8499a672182590e87 Author: Eugene Rozenfeld Date: Wed Dec 9 16:44:25 2020 -0800 Optimize combination of comparisons to dec+compare This patch adds patterns for optimizing x < y || y =3D=3D XXX_MIN to x <=3D y-1 x >=3D y && y !=3D XXX_MIN to x > y-1 if y is an integer with TYPE_OVERFLOW_WRAPS. This fixes pr96674. Tested on x86_64-pc-linux-gnu. For this function bool f(unsigned a, unsigned b) { return (b =3D=3D 0) | (a < b); } the code without the patch is test esi,esi sete al cmp esi,edi seta dl or eax,edx ret the code with the patch is sub esi,0x1 cmp esi,edi setae al ret PR tree-optimization/96674 gcc/ * match.pd: New patterns: x < y || y =3D=3D XXX_MIN --> x <=3D = y - 1 x >=3D y && y !=3D XXX_MIN --> x > y - 1 gcc/testsuite * gcc.dg/pr96674.c: New tests.=