[Bug tree-optimization/116024] [14/15 Regression] unnecessary integer comparison(s) for a simple loop since r14-5628-g53ba8d669550d3
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jul 21 17:15:56 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116024
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So the missed optimizations that VRP/PHIopt/match expose are:
```
unsigned f(void);
int i1(void)
{
int l = 2;
l = 3 - (int)f();
return l <= 2; // f() > 0
}
int i2(void)
{
unsigned l = 2;
l = 3 - (unsigned)f();
return l <= 2; // f() - 1 < 3
}
int i3(void)
{
unsigned l = 2;
l = 3 + (unsigned)f();
return l <= 2; // f() > -4u
}
int i4(void)
{
int l = 2;
l = 3 + (int)f();
return l <= 2; // f() < 0
}
```
This can be done even without knowing the range of `f()` here. and these is
done by clang already. Note GCC does handle i4 is already.
More information about the Gcc-bugs
mailing list