From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D72093858401; Mon, 1 Jan 2024 09:15:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D72093858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704100527; bh=TMaBQ89MEUIE/UiOehHakaA1gBv9LJ34/acR6YRLl3w=; h=From:To:Subject:Date:From; b=rQOXl3A2AT9bGpK7bDbzaSEjLJmfdNueCV5GOiD5C/yyaMpMrhe7QYknZgIayZmRE fSeQw41hqlYYBffXhmmUqBsP07Z52K1n3R8Bn2OWXfzU/8ZsvfJQX21okr+17xOhUC O2fING57E4uv9mUv6RaK7YNBAMh8SNZa4FNkO3AE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113187] New: `(X & C1) | C2` Simplifies to `A & (C1 | C2)` iff `(A & C2) == C2` Date: Mon, 01 Jan 2024 09:15:25 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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=3D113187 Bug ID: 113187 Summary: `(X & C1) | C2` Simplifies to `A & (C1 | C2)` iff `(A & C2) =3D=3D C2` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f(int X) { int C1 =3D 0x1; int C2 =3D 0x2; if ((X & C2) !=3D C2) __builtin_unreachable(); return (X & C1) | C2; } ``` This should be optimized to just `return X & 3;` as `X&0x2` is known to be already 0x2.=