https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111432

            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)!=0) __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.

Reply via email to