From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 04F153858D37; Fri, 1 Sep 2023 06:58:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04F153858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693551494; bh=wn0Y3vGhPY2w+YmIF9xzSvyb9TlFDs715rWyC0fbz/E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hJXkkEyXQ7v2itu8f/KNgeHWKkGTT2yjDCTRBNQdPRiQeFFZgitMXVGlSiNRdd1g8 fgUuMGxSYpUdWxxDEHErCWHt1qslxLsorw9hqXLs2am5mXMFsq/1STnxLqvu5s2O3g OiO6KYZtaJbI/QR2YULlcmM8fhve2Szqty0IA0UU= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/19832] don't remove an if when we know the value is the same as with the if (subtraction) Date: Fri, 01 Sep 2023 06:58:10 +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: 4.0.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: pinskia 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D19832 --- Comment #11 from CVS Commits --- The trunk branch has been updated by Andrew Pinski : https://gcc.gnu.org/g:3d86e7f4a8aef1b864a51660825597eafe9059b1 commit r14-3606-g3d86e7f4a8aef1b864a51660825597eafe9059b1 Author: Andrew Pinski Date: Wed Aug 30 21:21:01 2023 -0700 MATCH [PR19832]: Optimize some `(a !=3D b) ? a OP b : c` This patch adds the following match patterns to optimize these: /* (a !=3D b) ? (a - b) : 0 -> (a - b) */ /* (a !=3D b) ? (a ^ b) : 0 -> (a ^ b) */ /* (a !=3D b) ? (a & b) : a -> (a & b) */ /* (a !=3D b) ? (a | b) : a -> (a | b) */ /* (a !=3D b) ? min(a,b) : a -> min(a,b) */ /* (a !=3D b) ? max(a,b) : a -> max(a,b) */ /* (a !=3D b) ? (a * b) : (a * a) -> (a * b) */ /* (a !=3D b) ? (a + b) : (a + a) -> (a + b) */ /* (a !=3D b) ? (a + b) : (2 * a) -> (a + b) */ Note currently only integer types (include vector types) are handled. Floating point types can be added later on. OK? Bootstrapped and tested on x86_64-linux-gnu. The first pattern had still shows up in GCC in cse.c's preferable function which was the original motivation for this patch. PR tree-optimization/19832 gcc/ChangeLog: * match.pd: Add pattern to optimize `(a !=3D b) ? a OP b : c`. gcc/testsuite/ChangeLog: * g++.dg/opt/vectcond-1.C: New test. * gcc.dg/tree-ssa/phi-opt-same-1.c: New test.=