Tom Stellard
2014-Apr-04 01:29 UTC
[LLVMdev] How should I update LiveIntervals after removing a use of a register?
Hi, I am working on a simple copy propagation pass for the R600 backend that propagates immediates rather than registers. For example, I want to transform: ... %vreg1 = V_MOV_B32 1 %vreg2 = V_ADD_I32 %vreg1, %vreg0 ... into: %vreg1 = V_MOV_B32 1 ; <- Only delete this if it is dead %vreg2 = V_ADD_I32 1, %vreg0 For best results, I am trying to run this pass after the TwoAddressInstruction pass, which means I need to preserve the LiveIntervals analysis. My question is: How do I update the LiveIntervals to reflect the fact that V_ADD_I32 no longer uses %vreg0? Thanks, Tom
Andrew Trick
2014-Apr-05 07:36 UTC
[LLVMdev] How should I update LiveIntervals after removing a use of a register?
On Apr 3, 2014, at 6:29 PM, Tom Stellard <tom at stellard.net> wrote:> Hi, > > I am working on a simple copy propagation pass for the R600 backend that > propagates immediates rather than registers. For example, I want to > transform: > > ... > %vreg1 = V_MOV_B32 1 > %vreg2 = V_ADD_I32 %vreg1, %vreg0 > ... > > into: > > %vreg1 = V_MOV_B32 1 ; <- Only delete this if it is dead > %vreg2 = V_ADD_I32 1, %vreg0 > > For best results, I am trying to run this pass after the > TwoAddressInstruction pass, which means I need to preserve > the LiveIntervals analysis. > > My question is: How do I update the LiveIntervals to reflect the fact > that V_ADD_I32 no longer uses %vreg0?Hi Tom, Hopefully you figured this out ;) IIRC, the safe thing to do is call removeInterval and createAndComputeVirtRegInterval for both vreg0 and vreg1. -Andy
Tom Stellard
2014-Apr-07 14:01 UTC
[LLVMdev] How should I update LiveIntervals after removing a use of a register?
On Sat, Apr 05, 2014 at 12:36:19AM -0700, Andrew Trick wrote:> > On Apr 3, 2014, at 6:29 PM, Tom Stellard <tom at stellard.net> wrote: > > > Hi, > > > > I am working on a simple copy propagation pass for the R600 backend that > > propagates immediates rather than registers. For example, I want to > > transform: > > > > ... > > %vreg1 = V_MOV_B32 1 > > %vreg2 = V_ADD_I32 %vreg1, %vreg0 > > ... > > > > into: > > > > %vreg1 = V_MOV_B32 1 ; <- Only delete this if it is dead > > %vreg2 = V_ADD_I32 1, %vreg0 > > > > For best results, I am trying to run this pass after the > > TwoAddressInstruction pass, which means I need to preserve > > the LiveIntervals analysis. > > > > My question is: How do I update the LiveIntervals to reflect the fact > > that V_ADD_I32 no longer uses %vreg0? > > Hi Tom, > > Hopefully you figured this out ;) IIRC, the safe thing to do is call removeInterval and createAndComputeVirtRegInterval for both vreg0 and vreg1. >I found a slightly different solution, which was to call LiveIntervals::shrinkToUses(vreg1). This also gives me a list of dead instructions, which is nice. Are there an disadvantages to doing it this way? Thanks, Tom