napi@rangkom.MY (Mohd Hanafiah Abdullah) (04/02/91)
I would like to know what people think of the advantages/disadvantages of letting TEMPORARIES to fight for registers along side PROGRAM VARIABLES, as opposed to reserving the register allocation only for PROGRAM VARIABLES and pre-alloacate a fixed number of registers for TEMPORARIES. Please respond by email. Regards. Napi [Please mail responses both to him and to compilers; he gets compilers on tape via boat mail a month late. -John] -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
pardo@cs.washington.edu (David Keppel) (04/03/91)
napi@rangkom.MY writes: >[How about letting temporaries fight for registers rather than > just pre-allocating a fixed number of registers?] My off-the-hat response: If your IR contains only primitive machine operations and if register allocation is done on the IR, then that's probably what you're doing already. For example: C: x = y + z * x; IR: t1 = z * x; x = y * t1; Loop induction and unrolling are machine-independent optimizations (that may have machine-dependent profitability) which can add and delete program variables and can add long- lived temporaries. Most compilers will probably (I'm guessing) treat those compiler-introduced temporaries as variables, at for the register allocator. With statement-level or basic-block optimizations, most temporaries are ``very temps'' and only one or two are needed at any given time. Thus, on machines with a large number (~30) of registers, the differences between pre-allocation and integrated allocation will be small. For sophisticated optimizations, I do not know and do not care to guess. Merging variables and temporaries can, in general, cause a phase ordering conflict with instruction selection. Which instruction sequence the compiler picks may depend on how many registers are available. How many registers are avaialible depends on how many temporaries are in use. How many temporaries are in use depends on the instruction sequence. ;-D on ( Optim eyes ) Pardo -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.