This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Dce & infinite loops
Hello,
> > > >OK, I may easily extend the loop optimizer to remove empty loops if
> > > >there is a demand for it (once dce is fixed so that it is not done
> > > >even in cases it is incorrect, as happens now).
> > >
> > > How is the loop in your example different from a call to
> > > a non-terminating function returning void? I don't see
> > > why the optimizers would handle that correctly and not
> > > the infinite loop. Could you explain?
> >
> > I had in one of previous mails, but anyway: for the function we see it
> > has side effects (nontermination), so we mark it as neccesary. For the
> > loop we do not.
> >
> > The solution is obvious -- mark the backedges of the loops for that we are
> > not able to prove that they have to terminate as well.
>
> If we can eliminate empty loop bodies -- fine with me. One of the
> reasons why cd-dce does better than regular dce is because we kill
> such loops. Yes, they happen. When I looked at this, there were
> about 2 dozen times or so in the test case for PR8361, so they're
> not even that uncommon.
>
> Just always removing infinite loops is also not very hard to do.
> All we'd need to do is add fake edges for tree DCE. I decided
> against that because I thought that removing infinite loops was
> not a valid transformation. But if it is valid after all, I can
> put fake edges in, and all infinite loops will be removed.
>
> For me, the most important thing is consistency. Right now we
> do not remove infinite loops that are infinite because they have
> no loop exit, but we do kill infinite loops that are infinite
> because the exit condition can never be true. We should either
> remove all infinite loops, or none at all.
sorry, this is not up to us -- we must preserve *all* infinite loops to
be correct. Only if we are able to prove the loop must always terminate
we may remove it.
Zdenek