https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96563
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2020-08-11 00:00:00 |2021-8-19
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So I looked into this a little bit, clang is able to do it because it "unrolls"
the loop.
The reason why I say that is if you take:
int f(int x, int y)
{
int i = 0;
while (i <= y)
{
if (i == x)
return 8;
++i;
}
return 4;
}
No compiler is able to optimize this at all.
Which should get us: 4 + ((x <= y && x >= 0)*4).
Even changing the original 9 to 1000, clang does not do the optimization ....
>although of course it would be nice if it also worked for 99 instead of 9,
>where we are not going to unroll.
Yes it would but not even clang/LLVM does that :)