<div dir="ltr">Hi all,<div><br></div><div>I've come across a problem with register allocation which I have been unable to track down the root cause of.</div><div><br></div><div><div><font face="monospace, monospace">6728B<span class="" style="white-space:pre">          </span>%vreg304<def> = COPY %vreg278; VRF128:%vreg304,%vreg278</font></div><div><font face="monospace, monospace">6736B<span class="" style="white-space:pre">          </span>%vreg302<def> = COPY %vreg278; VRF128:%vreg302,%vreg278</font></div><div><font face="monospace, monospace">6752B<span class="" style="white-space:pre">          </span>%vreg278<def,tied1> = foo %vreg278<tied0>, %vreg277, 14, pred:1, pred:%noreg, 5; VRF128:%vreg278 VRF64_l:%vreg277</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">               </span>  * bar 30, %vreg278; VRF128:%vreg278</font></div><div><font face="monospace, monospace">6760B<span class="" style="white-space:pre">         </span>%vreg302<def,tied1> = foo %vreg302<tied0>, %vreg270, 14, pred:1, pred:%noreg, 5; VRF128:%vreg302 VRF64_l:%vreg270</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">               </span>  * bar 30, %vreg302; VRF128:%vreg302</font></div><div><font face="monospace, monospace">6768B<span class="" style="white-space:pre">         </span>%vreg304<def,tied1> = foo %vreg304<tied0>, %vreg263, 14, pred:1, pred:%noreg, 5; VRF128:%vreg304 VRF64_l:%vreg263</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">               </span>  * bar 30, %vreg304; VRF128:%vreg304</font></div></div><div><div><font face="monospace, monospace">6776B<span class="" style="white-space:pre">          </span>STORE128 %vreg302, <fi#32>, 0; mem:ST16[FixedStack32] VRF128:%vreg302</font></div><div><font face="monospace, monospace">6792B<span class="" style="white-space:pre">            </span>%vreg306<def> = COPY %vreg305; VRF128:%vreg306,%vreg305</font></div><div><font face="monospace, monospace">6796B<span class="" style="white-space:pre">          </span>%vreg375<def> = LOAD_v4i16 <fi#64>, 0, pred:1, pred:%noreg, 7; mem:LD8[FixedStack64] VRF64_l:%vreg375</font></div><div><font face="monospace, monospace">6800B<span class="" style="white-space:pre">              </span>%vreg306<def,tied1> = foo %vreg306<tied0>, %vreg375, 14, pred:1, pred:%noreg, 5; VRF128:%vreg306 VRF64_l:%vreg375</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">               </span>  * bar 30, %vreg306; VRF128:%vreg306</font></div><div><font face="monospace, monospace">6804B<span class="" style="white-space:pre">         </span>STORE128 %vreg304, <fi#33>, 0; mem:ST16[FixedStack33] VRF128:%vreg304</font></div></div><div><br></div><div>For this sequence of instructions, when allocating a register for <font face="monospace, monospace">%vreg375</font> the greedy register allocator chooses <font face="monospace, monospace">V15_l</font>. The problem here is that it had previously allocated <font face="monospace, monospace">V15</font> (<font face="monospace, monospace">V15_l</font> is a sub-register of <font face="monospace, monospace">V15</font>) to <font face="monospace, monospace">%vreg304</font>. <font face="monospace, monospace">%vreg304</font> is defined at 6768B and finally used at 6804B so the instruction <span style="font-family:monospace,monospace">LOAD_v4i16</span><font face="arial, helvetica, sans-serif"> at 6796B ends up clobbering the value in </font><font face="monospace, monospace">V15</font><font face="arial, helvetica, sans-serif"> before its last use. This is the output of the allocator itself:</font></div><div><br></div><div><div><font face="monospace, monospace">selectOrSplit VRF64_l:%vreg375 [6796r,6800r:0)  0@6796r w=1.#INF00e+00</font></div><div><font face="monospace, monospace">assigning %vreg375 to %V15_l: V15_e0 [6796r,6800r:0)  0@6796r V15_e1 [6796r,6800r:0)  0@6796r V15_e2 [6796r,6800r:0)  0@6796r V15_e3 [6796r,6800r:0)  0@6796r</font></div></div><div><br></div><div>And this is the live range of <font face="monospace, monospace">%vreg304</font> printed just before the allocation of <font face="monospace, monospace">%vreg375</font> started:</div><div><br></div><div><font face="monospace, monospace">%vreg304 [6728r,6768r:0)[6800r,6804r:1)  0@6728r 1@6800r</font><br></div><div><br></div><div>Why is <font face="monospace, monospace">V15_l</font> being allocated to <font face="monospace, monospace">%vreg375</font> when there is already a live value in <font face="monospace, monospace">V15</font>? Am I missing some meta-data on either of the instructions <font face="monospace, monospace">foo</font> or <font face="monospace, monospace">bar</font>? The instruction <font face="monospace, monospace">bar</font> doesn't clobber <font face="monospace, monospace">%vreg304</font>.</div><div><br></div><div>Thanks,</div><div>Stephen</div></div>