From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 523063858D28; Wed, 1 Dec 2021 07:33:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 523063858D28 From: "navidrahimi at microsoft dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/103514] New: Missing XOR-EQ-AND Optimization Date: Wed, 01 Dec 2021 07:33:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: navidrahimi at microsoft dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Wed, 01 Dec 2021 07:33:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103514 Bug ID: 103514 Summary: Missing XOR-EQ-AND Optimization Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: navidrahimi at microsoft dot com Target Milestone: --- We are not optimizing &&-^-=3D=3D combination, LLVM does it [1]: // Proof of correctness https://alive2.llvm.org/ce/z/a4tuWF bool src (bool a, bool b) { return (a && b) =3D=3D (a ^ b); } bool tgt (bool a, bool b) { return !(a || b); } // Proof of correctness https://alive2.llvm.org/ce/z/w-iotd bool src (bool a, bool b) { return (a && b) ^ (a =3D=3D b); } bool tgt (bool a, bool b) { return !(a || b); } I will be sending a patch for this. This will solve it, I have to run the testsuite and write a few tests: /* (a && b) first_op (a second_op b) -> !(a || b) */ (for first_op (bit_xor eq) (for second_op (bit_xor eq) (simplify=20 (first_op:c (bit_and:c truth_valued_p@0 truth_valued_p@1) (second_op:c @0 @1)) (if (first_op !=3D second_op) (bit_not (bit_ior @0 @1)))))) 1) https://compiler-explorer.com/z/WqTxYhG3s=