[tree-ssa] Dce & infinite loops

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Thu Mar 18 12:38:00 GMT 2004


Hello,

> > I may be wrong, but IIRC it is incorrect to remove infinite loops, as
> > happens currently for example for the following code:
> >
> > int main(void)
> > {
> >   unsigned i;
> >
> >   for (i = 1; i != 0; i+=2);
> >
> >   return 0;
> > }
> 
> Removing an infinte loop is indeed wrong.  Hence this comment
> in tree-ssa-dce.c:
> 
>   /* Some blocks don't have an immediate post dominator.  This can happen
>      for example with infinite loops.  Removing an infinite loop is an
>      inappropriate transformation anyway...  */
> 
> If we remove that infinite loop, you found a bug.

the problem is that the loop in the example above has an exit (that is
never taken); therefore the code in tree-ssa-dce.c you cite does not
handle it.

Zdenek



More information about the Gcc mailing list