From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AC71E3858D33; Sat, 16 Sep 2023 04:11:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC71E3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694837496; bh=QX0h4Yw7RDw2aB7BHNbo5BjNfQkLH/DdQNv7pBowO7w=; h=From:To:Subject:Date:From; b=sMRdvVn22OX7qx3V+4Gsd/q9ayvDwTRDOt2YHphYYWF8bF7v+khBKrJ0X7TyzO+3h Iuc5ZtlDimkbJon3zRWRH2ozlZ1pmcmfeLJm8dzj76dRcJit/6u8H5AbKaW+gSbZoi TVAMv4PoznW9R3hQ2qG3QefNIv70F2JgXw5ZjiPw= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111432] New: `bool & (a|1)` is not optimized to just `bool` Date: Sat, 16 Sep 2023 04:11:36 +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: 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=3D111432 Bug ID: 111432 Summary: `bool & (a|1)` is not optimized to just `bool` Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- take: ``` int foo3(int c, int bb) { if ((bb & ~3)!=3D0) __builtin_unreachable(); return (bb & (c|3)); } int foo_bool(int c, _Bool bb) { return (bb & (c|7)); } ``` foo3 should be optimized to just `return bb`, likewise for foo_bool. Note LLVM does this.=