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

            Bug ID: 111766
           Summary: Missed optimization with __builtin_unreachable and
                    ands
           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
foo3n(int c, int bb)
{
  if ((bb & ~3)!=0) __builtin_unreachable(); // bb = [0,3]
  if ((bb & 1)==0) __builtin_unreachable(); // bb&1 == 0 // [0],[3]
  if(bb == 2) __builtin_trap();
  return bb;
}
```

The condition `bb == 2` is never true as (bb&1) has to be zero.

I Noticed this while looking into PR 111432.  Note clang/LLVM is able to
optimize this ...

Reply via email to