From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D398A3858CDA; Sat, 4 Nov 2023 21:43:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D398A3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699134228; bh=Z4TYdrOo/UnZ+eG05T5Tn9y+YWmej4LUjc57hYFPGcg=; h=From:To:Subject:Date:From; b=ErT9787+zjgXm7aTP/dKRUnVOUL0HhFdlD/I+JyMVgjOEaDqmp9ZT3K9YazaLGEZS b9HvH17YNiSEK71wNTPzayKQ96XM23hUswG+FQaj5XrSDLehdI9608mzLnfdlXr/p1 PliXtvPfq8DNps+PZVzE9JQBedgcaiem7VY3gOdo= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112383] New: `a&=CST; (a&b) != a` and `((~b) & a) & CST != 0` Date: Sat, 04 Nov 2023 21:43:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end 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: 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 keywords 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112383 Bug ID: 112383 Summary: `a&=3DCST; (a&b) !=3D a` and `((~b) & a) & CST !=3D 0` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f1(unsigned a, unsigned b) { a &=3D 0x11; return (a&b) !=3D a; } int f2(unsigned a, unsigned b) { int d =3D 0x11; int e =3D (~b) & a; return (e&d) !=3D 0; } ``` These 2 should produce the same code. Likewise for: ``` int fn1(unsigned a, unsigned b, unsigned c) { a &=3D c; return (a&b) !=3D a; } int fn2(unsigned a, unsigned b, unsigned c) { int d =3D c; int e =3D (~b) & a; return (e&d) !=3D 0; } ``` Note clang (LLVM) only produces the same code for f1/f2 pair, it misses the Canonicalization for fn1/fn2 too. Note for gimple f1/fn1 is simplier and most likely should be canonical.=