Empty loop elimination in 4.0 ?
Zdenek Dvorak
rakdver@atrey.karlin.mff.cuni.cz
Mon Jan 10 12:06:00 GMT 2005
Hello,
> > > 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/
as I said, it is implemented.
> approved it?
Yes.
> Is there any chance that this patch will be commited by the release
> of 4.0 ?
I don't thing so; this is not a regression, and we are in stage 2.
> Is there a PR associated with that patch?
No.
> 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?
No, as far as I can tell. The reason why this does not happen
is that implementing this transformation is relatively complicated
and I don't think it would be very useful in practice.
Zdenek
More information about the Gcc
mailing list