From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A9B353858401; Thu, 12 Oct 2023 17:16:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9B353858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697131000; bh=sknXSXg8XZafYfq5orMQdnw8bIivvrzQg72fY+XITkY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=V4n8KV88qiaJAs2SIkGwI9qzzRVgJpuoWnSWTyE5PGfVWiaZx6JEQ/vj01jgt+Vc2 rylxcvcSmFhKg+dhuIgwh0d4KVGDDccSjC19cf37e0iz/IPv39l0+Iw5dZJ+ZiC2s7 J8+y5IacNzEIX3qUK/HWGglabs4SYAzIFroVl/eE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/88280] missing folding of logical and bitwise AND Date: Thu, 12 Oct 2023 17:16:40 +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: 9.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: bug_status assigned_to 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=3D88280 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot = gnu.org --- Comment #5 from Andrew Pinski --- Match pattern: ``` (for cmp (eq ne ) bop (bit_ior bit_and) (bop:c (cmp @0 integer_zerop) (cmp@2 (bit_and:c @0 @1) integer_zerop)) @2) ``` testcase that shows the issue (of the swapped order of the ifs) ``` _Bool f0(int a, int b) { if (a =3D=3D 0) return 1; return (a & b) =3D=3D 0; // (a=3D=3D0) | ((a &b) =3D=3D 0) -> ((a &b) =3D= =3D 0) } _Bool f0_(int a, int b) { if ((a & b) =3D=3D 0) return 1; return a =3D=3D 0; // ((a &b) =3D=3D 0) | (a=3D=3D0) -> ((a &b) =3D=3D 0) } _Bool f1(int a, int b) { if (a !=3D 0) return (a & b) !=3D 0; return 0; // (a!=3D0) & ((a & b) !=3D 0) -> ((a & b) !=3D 0) } _Bool f1_(int a, int b) { if ((a & b) !=3D 0) return a !=3D 0; return 0; // ((a & b) !=3D 0) & (a!=3D0) -> ((a & b) !=3D 0) } ```=