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

            Bug ID: 111595
           Summary: detection of MIN/MAX with truncation and sign change
                    for the result
           Product: gcc
           Version: 14.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:
```
unsigned short f(long a, long b)
{
        short as = a;
        short bs = b;
        unsigned short asu = a;
        unsigned short bsu = b;
        if (as < bs) return asu;
        return bsu;
}
unsigned short f0(long a, long b)
{
        short as = a;
        short bs = b;
        unsigned short asu = a;
        unsigned short bsu = b;
        if (as < bs) return as;
        return bs;
}

unsigned short f1(long a, long b)
{
        short as = a;
        short bs = b;
        unsigned short asu = a;
        unsigned short bsu = b;
        signed short t;
        if (as < bs) t = as;
        else t = bs;
        return t;
}
```

Currently only f1 detects MIN here. They all should produce the same IR in the
end.

Reply via email to