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

            Bug ID: 119422
           Summary: `u <= (u <= (unsigned)b)` can be transform into just
                    `(u <= (unsigned)b)`
           Product: gcc
           Version: 14.1.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 gg(unsigned u, bool b)
{
  return u <= (u <= (unsigned)b);
}

int gg1(unsigned u, bool b)
{
  if (u <= (unsigned)b)
    return u <= 1;
  return u <= 0;
}

int gg2(unsigned u, bool b)
{
  return u <= (unsigned)b;
}
```

gg should produce the same as gg1 and gg2. gg1 shows how it is true.

Reply via email to