[Bug c++/59845] loop optimization problem when profiling
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 16 19:18:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59845
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>(constant folding problem within loop?)
No it is doing the following:
if (n>=1)
{
i = 1;
while (true)
{
if (n%i == 0)
{
printf("\n%d", i);
i++;
if (n/2 < i) break;
}
else
{
i++;
if (n/2 < i) break;
}
}
}
Notice the load from n is not pulled out of the loop and that is because the
compiler thinks n escapes via scanf.
More information about the Gcc-bugs
mailing list