------- Additional Comments From law at redhat dot com  2004-12-28 08:22 -------
A few more notes.

I would suggest starting the testcase in comment #8.  While the simpler
testcase shows the underlying issue, it's simplified so far that the "problem"
could be fixed in various ways which totally avoid the copy, but which do not
help the larger testcases.

If we go back to the testcase in comment #8 and analyze the code closely we
will see that a copy is inevitable.  If we copy propagate into the PHI, then
the copy gets inserted into its own block.  If we do not copy propagate
into the PHI, then the copy sits just before the loop exit test.  Having the
copy before the loop exit test rather than splitting the loop backedge is
better for a number of reasons.

So the issue at hand is not an extraneous copy, but instead the *placement*
of that copy.

We queue the copy to be inserted on the backedge of the loop, which is clearly
a correct insertion point.  However, if we use life analysis we can determine
that we can place the copy before the loop exit test.  The out-of-ssa code
computes object lifetimes, so, in theory we have the information we need.

What we'd need to do is enhance the copy placement code to be a little smarter
when we want to insert a copy on a critical edge.  Given a copy dest = src 
that we want to place on a critical edge E, we'd want to check if dest is
live on any of the other edges in e->src->succs -- if dest is not live on
any of those edges, then we can place the copy at the end of e->src.  Or
something along those lines.

I have no idea how hard that would be to implement within the current
out-of-ssa framework we have in place.

It's worth nothing that copy placement on loop backedges for out-of-ssa has
been an area that has been problematical before.  I ran into a number of
regressions in the RTL SSA code with poor placements (mostly in ways that
confused the old old rtl loop optimizers).  So it's not a _huge_ surprise
that we're seeing some issues in the same areas with the tree out-of-ssa code.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19038

Reply via email to