Open
Description
The repeated computation of a maximum/minimum is not hoisted outside of a loop, preventing the elimination of the loop (instead, the loop gets pointlessly vectorized).
Example (https://godbolt.org/z/faM4od4dM; see also: https://alive2.llvm.org/ce/z/YqPC82)
#include <cstdint>
uint8_t f(uint8_t n, uint8_t a, uint8_t b) {
for (uint8_t i = 0; i < n; i++)
a = a < b ? b : a;
return a;
}
To me this looks like something that SCEV should recognize (I might be wrong here, but in the end, the loop should get eliminated).