[Bug tree-optimization/107887] New: (bool0 > bool1) | bool1 is not optimized to bool0 | bool1

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Nov 27 18:59:44 GMT 2022


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

            Bug ID: 107887
           Summary: (bool0 > bool1) | bool1 is not optimized to bool0 |
                    bool1
           Product: gcc
           Version: 13.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 max(_Bool aa, _Bool bb)
{
  bool t = aa > bb;
  return t | bb;
}
```
This should be optimized to just `return aa | bb;`
I accidently found this while working on PR 101805 .

The original testcase which I found it:
```
int ii(_Bool aa, _Bool bb)
{
  int c;
  int a = aa;
  int b = bb;
  if (a > b)
    c = a;
  else
    c = b;
  if (c)
    return 100;
  return c;
}
```


More information about the Gcc-bugs mailing list