[Bug tree-optimization/53265] Warn when undefined behavior implies smaller iteration count
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 7 14:21:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53265
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-05-07
Ever Confirmed|0 |1
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-05-07 14:10:48 UTC ---
Confirmed.
It's not so simple as cases I have seen do not involve a statically constant
nb_interations. Consider
enum {N=4};
int a[N], pfx[N];
void foo(int n)
{
int i, accum;
for (i=0, accum=a[0]; i < n; i++, accum+=a[i])
pfx[i] = accum;
}
and calling that with n == 4.
I was suggesting to warn about optimizing a loop exit test to never stop
iterating.
More information about the Gcc-bugs
mailing list