Hello,
although usage of rewrite_ssa_into_ssa for loop header copying is quite
simple and elegant, there is one important flaw -- rewrite_ssa_into_ssa
is currently not effective enough to be usable as a subroutine inside
the optimization (i.e. it is fine to run it once or twice per function,
but running it once for each loop in function would not work). Since
I need to use loop header copying as a subroutine, I have implemented
the
transformation directly.
There is a small drawback in comparison with the rewrite_ssa_into_ssa
approach -- the produced ssa form is not minimal, since we create
new phi node for each ssa name defined in the header (not just for
those
used outside the header). To avoid this, we would need to scan whole
body of the loop for uses, which seems unnecesarily compile time
consuming to
me. Andrew, how far are you with your immediate uses patch? This
would
be one of the places where it would be really nice to have it.
The patch partially duplicates the functionality I have previously
written in tree-ssa-loop-manip.c. I consider some of the approaches
I used in this patch a bit more clean, and plan to rewrite the
tree-ssa-loop-manip.c functions to use them.
I needed to disable the PRE pass, since the patch exposes some bug in
it
(Steven is working on fixing the problem).