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

--- Comment #4 from Drea Pinski <pinskia at gcc dot gnu.org> ---

Note `x + uMax(x, 1) -> uMax(x+x, 1)` is a special case of `minmax (a, b) + c
-> minmax (a + c, b + c)`.  

That is:
```
  t_4 = a_3(D) * 2;
  a_5 = a_3(D) + 1;
  _6 = MAX_EXPR <t_4, a_5>;
```
Can be optimized to `MAX_EXPR <t_4, 1>` as t_4 min is 0 while a_5 min is 1.

```
unsigned t(unsigned a)
{
    if (a > __INT_MAX__)
      return 0;
    unsigned t = a*2;
    a+=1;
    return t < a ? a : t;
}
```
LLVM handles the above but not the `x + uMax(x, 1)` for some reason. I didn't
look into why. Anyways the second pattern is enough for remove the `>=` in the
original testcase too. Though I don't understand why my reduced testcase fails
for LLVM; even though the original code (of push_back) works; not my worry.

Reply via email to