Empty loop elimination in 4.0 ?
Richard Guenther
richard.guenther@gmail.com
Mon Jan 10 14:25:00 GMT 2005
On Mon, 10 Jan 2005 08:49:00 -0500, Robert Dewar <dewar@adacore.com> wrote:
> I think it is always a good idea to generate a warning
> when an empty loop is detected (whether or not it is
> eliminated), since this is either a timing loop, or it
> is likely a bug.
Especially as while we preserve empty loops, we do not preserve the number of
iterations! And for loops with small number of iterations, we may
remove it completely
already. All of this happens with -funroll-loops.
Experimenting a little bit, even for
void foo(void)
{
int i = -3;
while (++i)
;
}
the loop is removed completely with -funroll-loops, with i=-1024 we
get a loop with
increments of 8.
I'd certainly vote for a warning and removal of all empty loops.
Richard.
More information about the Gcc
mailing list