From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BABFA385800A; Sat, 26 Nov 2022 17:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BABFA385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669484479; bh=NMuAyaiFKU6M39/B1md86gV3G3euc6KprRNrY1BjPsA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pDJ+8EJfh4Ixv4W+ulB3DK/MBeT7QFPiR4wJCnoR5sgUx1x+5UZ5UTB8GXWNyk/tT eoFvRQ9tCzDoRlJuxsgPR+YSRgr7o6GmUspm0ekOkU8PKyM71OXbQn2TgDLdKNUCjA 3VHgihF9G4N29oZwi+Nua0zq0LGPbkJt+78kZWrY= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/91882] boolean XOR tautology missed optimisation Date: Sat, 26 Nov 2022 17:41:19 +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: 10.0 X-Bugzilla-Keywords: easyhack, missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: dependson 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=3D91882 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |103356 --- Comment #6 from Andrew Pinski --- After my patch for PR 103356, this is fixed. Before pre: _1 =3D a_4(D) ^ b_5(D); _2 =3D a_4(D) | b_5(D); if (_2 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870913]: _6 =3D a_4(D) & b_5(D); _9 =3D ~_6; [local count: 1073741824]: # iftmp.0_3 =3D PHI <_9(3), 0(2)> _7 =3D _1 =3D=3D iftmp.0_3; After PRE (after my patch): _1 =3D a_4(D) ^ b_5(D); _2 =3D a_4(D) | b_5(D); if (_2 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870912]: _10 =3D ~_1; goto ; [100.00%] [local count: 536870913]: // _6 =3D a_4(D) & b_5(D); // _9 =3D ~_6; [local count: 1073741824]: # iftmp.0_3 =3D PHI <_9(4), 0(3)> # prephitmp_11 =3D PHI <_2(4), _10(3)> return prephitmp_11; And then dom comes and does (because if (a|b) =3D=3D 0 then both a and b ar= e zero and a^b =3D=3D 0 and ~(a^b) is 1): [local count: 1073741824]: _2 =3D a_4(D) | b_5(D); if (_2 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870912]: _1 =3D 0; _10 =3D 1; [local count: 1073741824]: # prephitmp_11 =3D PHI <1(2), 1(3)> return 1; Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103356 [Bug 103356] bool0 =3D=3D ~bool1 should simplify to bool1 ^ bool0=