This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Empty loop elimination in 4.0 ?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]