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

            Bug ID: 128100
           Summary: `std::max({a,b,c})` is not optimized at -Os
           Product: gcc
           Version: 17.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:
```
#include <algorithm>

int testA(int a, int b, int c) {
  return std::max(std::max(a, b), c);
}

int testB(int a, int b, int c) {
  return std::max({a, b, c});
}
```

testA is optimized but testB's array is still stored to the stack at -Os.
The loop is gone since GCC 15.  I think the complete unroll at -Os happens late
while at -O2 happens earlier and there is no phiprop pass after the loop
optimizers.

Reply via email to