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

            Bug ID: 127102
           Summary: UMIN<a, b> != 0 should reduce to b != 0 when a is
                    known not to be zero
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: easyhack, missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
            Blocks: 127101
  Target Milestone: ---

Take:
```
unsigned f(unsigned l1, unsigned c)
{
  if (c==0) __builtin_unreachable();
  unsigned m = l1 > c ? c : l1;
  return m != 0;
}
```

This should reduce to just `return l1 != 0`.  LLVM can do this.

I think this is the first step in fixing PR 127101.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127101
[Bug 127101] a+b when b is non-zero and it is known there is no overflow (due
to a check) implies a+b is non-zero

Reply via email to