# New Ticket Created by Patrick R. Michaud # Please include the string: [perl #37578] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37578 >
>From a discussion earlier today on #irc... It would be nice if the PIR compiler had a way to use a very basic register allocation algorithm for .subs that use only a small number of registers. As I understand the current state of things, the PIR compiler performs a fairly complex analysis of a sub's control flow in order to make optimal use of registers in the sub. For long subs with lots of branches and control structures, this analysis can take a very long time... and may be unnecessary if the sub is using only a small number of named and temporary registers. If the number of named and temporary registers in a sub is small (for suitably values of "small"), the compiler can avoid the control flow analysis altogether by simply allocating registers for each .local, .param, or temporary register encountered and leaving those fixed for the life of the .sub. As a real-world instance of this, the PIR-code subroutines produced by PGE have the potential to become very long and contain a large number of control-flow statements, but use a maximum of 10 pmc, 9 int, and 4 string registers for the entire sub. (In the long run PGE may emit code using something other than PIR, but this is what we're doing for now.) The PIR compiler could be set to automatically detect the number of register used in a sub and then decide the register allocation method to use. Or, to simplify implementation, perhaps the choice of register allocation could be provided as an :option of some sort in the .sub line. I don't know enough about the PIR compiler internals to make this happen myself, which is why I'm submitting this as a TODO ticket (at Leo's request). Thanks, Pm