Subregister liveness tracking

I've been working on patches to improve subregister liveness tracking on llvm and I wanted to inform the llvm community about the overal design/motivation for them. I will send the patches to llvm-commits later today.

Greetings
     Matthias Braun

Subregisters in llvm

Hi,

I have a question about the way sub-registers are spilled and restored that is related to the changes I made in r192119.

Suppose I have the following piece of code with four instructions. %vreg0 and %vreg1 consist of two sub-registers indexed by sub_lo and sub_hi.

instr0 %vreg0instr1 %vreg1:sub_lo<def,read-undef>

instr2 %vreg0

instr3 %vreg1:sub_hi

If register allocator decides to insert spill and restore instructions for %vreg0, will it spill the whole register that includes sub-registers lo and hi?

instr0 %vreg0
spill0 %vreg0

instr1 %vreg1:sub_lo<def,read-undef>

spill1 %vreg1:sub_lo
restore0 %vreg0

instr2 %vreg0
restore1 %vreg1:sub_lo

instr3 %vreg1:sub_hi

Or will it spill just the lo sub-register?

instr0 %vreg0
spill0 %vreg0:sub_lo

instr1 %vreg1:sub_lo<def,read-undef>

spill1 %vreg1:sub_lo
restore0 %vreg0:sub_lo

instr2 %vreg0
restore1 %vreg1:sub_lo

instr3 %vreg1:sub_hi

If it spills the whole register (both sub-registers lo and hi), the changes I made should be fine. Otherwise, I will have to find another way to prevent the problems I mentioned in r192119’s commit log.