[tree-ssa] Walking blocks in reverse

Andrew MacLeod amacleod@redhat.com
Fri Apr 4 22:18:00 GMT 2003


On Fri, 2003-04-04 at 16:54, Diego Novillo wrote:
> On Fri, 04 Apr 2003, Andrew Macleod wrote:
> 
> > Is this OK to check in? Or would you rather I keep it local to the live
> > range code for now?
> > 
> The only time I've needed to walk blocks backwards I've done
> something similar.  In tree-ssa.c:rewrite_block we need to walk
> back undoing certain things we did on the forward walk.  What we
> do there is while doing the forward walk keep a stack of the
> events we will want to unwind at the end.  This way we avoid
> walking *all* the statements.
> 

Live range stuff will need to walk every stmt... 
I suppose you could use the same routines in rewrite_block to push just
the iterators you do care about, and pop them off later...
.
> I guess you can't do something similar in the live range code,
> right?
> 
Yeah, in the live range code, we dont want anything forward... We just
want to make a pass, backwards.  The coalescer will either go backwards
as well, or an additional structure is needed to mark which uses are the
last use in a live range.

> So, I think it's fine.  I was thinking of another alternative,
> have bsi_last() do the forward walk creating the stack which is
> then stashed in the iterator.  Then bsi_prev() will just unwind the
> stack.  But that would mean adding another word to the block
> iterator structure.  Which penalizes every use of the iterators.
> 
> Your approach is better because it's only needed when some pass
> needs to walk a block backwards.
> 

Hrm. On the other hand, now that I look at it a little closer, I
probably dont need the whole iterator, just the bsi_stmt() tree.. so I
can use VARRAY_TREE instead of all this stuff... Maybe I'll just hold
onto this patch for a while in case it needed later. I dont think I need
it at the moment. If someone else does, I'll check in in, otherwiseI'll
just do something local with varrays.

Andrew




More information about the Gcc-patches mailing list