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

            Bug ID: 127299
           Summary: phiopt should move conversions for all boolean to int
                    conversions and not just if there are 2 statements in
                    the condition
           Product: gcc
           Version: 17.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
            Blocks: 126043
  Target Milestone: ---

Take:
```
int t1 (int a, short b, int c)
{
  if (a > 0)
  {
    return c != b;
  }
  return 1;
}
```


This should optimize to `a > 0 & (c != (int)b)` with `-O2 --param
logical-op-non-short-circuit=1` but currently does not because we don't factor
out the convert at the end.

This is dirived from ssa-ifcombine-ccmp-9.c.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126043
[Bug 126043] early phiopt should allow CMP, (cast)CMP, -(cast)CMP

Reply via email to