https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111439
            Bug ID: 111439
           Summary: some boolean related transformation to `~(a&b)`
           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
```
bool foo0(bool a, bool b)
{
    return (a <= b) ^ a;
}
bool foo1(bool a, bool b)
{
    return (!a | b) ^ a;
}
bool foo2(bool b, int x, int y)
{
    bool a = x == y;
    return (!a | b) ^ a;
}
```

These all should be optimized to `~(a&b)`.
Right now foo1 is optimized at -O2 but not -O1 due to PR 111149 (canonical form
of a ^ b or a != b for booleans).
foo2 can be handled at -O2 if we use bitwise_inverted_equal_p instead of
bitwise_equal_p (with bit_not).

foo0 will just need a new pattern really. we do need to make a decision on the
canonical form, is it `~a | b` or `a <= b` but both show currently too.

Reply via email to