From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C18B3385C6C6; Fri, 9 Aug 2024 18:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C18B3385C6C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1723228810; bh=AqZfxS2K+sIxv3YxDQeizBzrF9YKE71QR9XF0GsjkGw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Y10cphJixPyB2nadtyHETyZEEZJj4aWJaLliFPNrtXFzCeHuntes56n7QoODK7s74 oVyxJXBQDMwM+fpxlYcZ7CqobNAG5g+VRNofQZP79BA371r8+Mytg752LYYMm+3aIw 2/WySsI0o0zheOzYZQ8hbp5WnZNBo0SP29/cBo/E= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103660] Sub-optimal code with relational operators Date: Fri, 09 Aug 2024 18:40:09 +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: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 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=3D103660 --- Comment #5 from Andrew Pinski --- Two more cases, this time with XOR (^): ``` int min7(int a, int b) { const int c =3D a < b; return (c * a) ^ ((1 - c) * b); } int min8(int a, int b) { const bool c =3D a < b; return (c * a) ^ (!c * b); } ``` Because `0 ^ a` is `a`. Should be easy to change the pattern to accept all 3 (XOR, IOR and PLUS) instead of just IOR.=