From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8C3943857C46; Mon, 18 Dec 2023 19:03:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C3943857C46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1702926225; bh=hmz3eGrPS0jmvFOVCMElWmGihNc4bN07whAuAOsYrHk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gGSoQThTkcjD5J3rGQtTr/4tUPwpyrr1N+BtriNIjQMfyx5gsWzU8AFyx4WPS+Sqs MMhCwJauuGqrgbDlW6tTBaINg5cL/WLpH433xT4OM7gSs8bic2mORZM1JtkkVeo0C+ a0GB02AIMWEKTtHLRKhQcGKRdPUx6A7VizfemjeE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113072] `(a ^ CST0) & (~a ^ CST0)` is not optimized to 0 at the gimple level Date: Mon, 18 Dec 2023 19:03:45 +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: TREE X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113072 --- Comment #1 from Andrew Pinski --- Wait this part is wrong `which does basically `(a ^ 4) & (a ^ (~4))` -> `(4= ^ (~4)) & (a ^ a)` which is 0 as `a ^ a` is 0.` Anyways a pattern like: ``` (simplify (bit_and (bit_xor @0 @1) (bit_xor @0 @2)) (with { bool wascmp; } (if (bitwise_inverted_equal_p (@1, @2, &wascmp)) { wascmp ? constant_boolean_node (false, type) : build_zero_cst (type); = }))) ``` Is needed for bool.=