From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 96330383583A; Thu, 21 Jul 2022 21:27:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 96330383583A From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94920] Failure to optimize abs pattern from arithmetic with selected operands based on comparisons with 0 Date: Thu, 21 Jul 2022 21:27:39 +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: 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: Thu, 21 Jul 2022 21:27:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94920 --- Comment #2 from CVS Commits --- The trunk branch has been updated by Sam Feifer : https://gcc.gnu.org/g:633e9920589ddfaf2d6da1c24ce99b18a2638db4 commit r13-1785-g633e9920589ddfaf2d6da1c24ce99b18a2638db4 Author: Sam Feifer Date: Thu Jul 21 16:31:41 2022 -0400 match.pd: Add new abs pattern [PR94920] This patch is intended to fix a missed optimization in match.pd. It optimizes (x >=3D 0 ? x : 0) + (x <=3D 0 ? -x : 0) to just abs(x). Addition= ally, the pattern (x <=3D 0 ? -x : 0) now gets optimized to max(-x, 0), which hel= ps with the other simplification rule. Tests are also included to be added to the testsuite. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? PR tree-optimization/94920 gcc/ChangeLog: * match.pd (x >=3D 0 ? x : 0) + (x <=3D 0 ? -x : 0): New simplification. (x <=3D 0 ? -x : 0): New simplification. gcc/testsuite/ChangeLog: * g++.dg/pr94920-1.C: New test. * g++.dg/pr94920.C: New test. * gcc.dg/pr94920-2.c: New test.=