This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Empty loop elimination in 4.0 ?
- From: Michael Veksler <VEKSLER at il dot ibm dot com>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 10 Jan 2005 09:41:25 +0200
- Subject: Re: Empty loop elimination in 4.0 ?
Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> wrote on 10/01/2005
02:07:21:
>
> > In the days of gcc-2.6.x the documentation of gcc said that empty loops
> > were not eliminated. The docs used to say that this was on purpose -
> > because empty loops were being used as delay loops.
> >
> > Does this ancient and not portable delay-loop hack still work with
> > gcc version 4.0.0 20050102 (experimental) ?
>
> yes. Although I think documentation about this was changed
> and it is no longer guaranteed that the empty loops are not
> removed. Also a patch for removing empty loops was submitted.
>
If there is no guarantee to keep the loop, why is it kept in practice?
Is it because nobody implemented/approved it?
Is there any chance that this patch will be commited by the release
of 4.0 ? Is there a PR associated with that patch? Current GCC behavior
is unreasonable.
Most code wants to execute as fast as possible or be as small as
possible (loop elimination is good for both). Any exception to that,
should pay the price (via extensions, or 'asm').
Another thing I noticed is that things like
const int k = f();
while(....)
{
a=0;
for(i=0; i <k ; i++ )
a= a*2; /* only 'a' is accessed in inner loop. */
.....
/* read and write to 'a' */
}
Are not transformed to:
a=0;
for(i=0; i <k ; i++ )
a= a*2; /* only 'a' is accessed in inner loop. */
{ /* new BB to make it valid for C89 */
const int a0 = a;
while(...)
{
a = a0;
.....
/* read and write to 'a' */
}
Does it have anything to do with recent jump threading
discussions?