reusing pseudo-regs

Stephen Weeks MLton@sourcelight.com
Fri, 1 Mar 2002 08:29:40 -0800


> Reuse pseudo-regs.  While this doesn't shrink the size of the final
> executable (because the pseudo-reg space is compiled into the BSS
> section), it should reduce the size of the in-memory executable image.
> Also, we could get better cache performance by reusing pseudo-regs.

Cool.  That was something I'd been wanting to do.  I'll be interested
to see if there is a performance improvement.

BTW, here are a couple of other things that were on my todo relating
to pseudo-reg allocation.

1. Use targeting info to avoid shuffles
2. Use liveness info at a statement granularity

(1) can be achieved by building an undirected graph where nodes
correspond to RSSA variables and there is an edge from a to b if a is
ever moved into b.  Then, when allocating a variable (for the stack),
take the free register (slot) with the most moves to or from a
variable that has already been assigned that register (slot).

For (2), the idea is when processing a block, count the number of
occurrences of each variable, where if it is live at the end that
counts as an occurrence too.  Then, while walking forward over block
allocating registers/slots, decrement variable counts when uses are
encountered.  If a count reaches 0, the variable is dead and can be
removed from the allocation.