From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 606B93858D35; Tue, 3 Oct 2023 03:12:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 606B93858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696302760; bh=9otGEnk2eDopOFR2kwJGJ29ZZ+/vxNXAsi8fOjBfuIo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d8DSpGqbZfIGOJyECuAehikEWQ3gDmSpvrHq/wS/a1jYKDjY5YYT4HsrKkJ+onChc ZoJNAEUl1XLhgwxotl37rDSe79SScQjvvhMYklLspo0JDjCuoj8XsrLP9YwSzzWOHg hKNSSbvqa4P6BneEkoHXicFm/hMwDVmL6W1JSbhE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111282] `a & (b ^ ~a)` (or `a & ~(a ^ b)`) not optimized to `a & b` in gimple Date: Tue, 03 Oct 2023 03:12: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: 14.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=3D111282 --- Comment #3 from Andrew Pinski --- (In reply to Andrew Pinski from comment #1) > Note we will need to detect both `a & (b ^ ~a)` and `a & ~(a ^ b)` since a > might be comparison too. Well and that will handle: ``` int f0(int a, int b) { return (~a) & (b ^ a); // ~a & b } ``` Which we don't currently. on the RTL level, we currently simplify that to: (a | b) ^ a The interesting thing is we do simplify the above in tree via the following pattern: /* (X | Y) ^ X -> Y & ~ X */=