<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Tom,<div><br></div><div>I’ve looked at your patch and it looks like a workaround to a more general issue.</div><div><br></div><div>I’ve applied your second patch and looked at what happen with the rematerialization in that case.</div><div><br></div><div>Unless I am not looking at the right fragment, the copy you are trying to avoid to rematerialize is:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  %vreg169<def> = COPY %vreg91:sub0_sub1; SReg_64:%vreg169 SReg_128:%vreg91</div></div><div><br></div><div>And the related rematerializable definition is:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  %vreg91:sub0_sub1<def,read-undef> = S_MOV_B64 0; SReg_128:%vreg91</div></div><div><br></div><div>Thus, one would expect to rematerialize this into:</div><div><span style="font-family: Menlo; font-size: 11px;">  %vreg169:sub0_sub1<def,read-undef> = S_MOV_B64 0; SReg_128:%vreg169</span></div><div><br></div><div>Which the current code should correctly handle.</div><div><br></div><div>However, in your case, the instruction that have been picked up for rematerialization is:</div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  %vreg91:sub3<def> = S_MOV_B32 61440; SReg_128:%vreg91</div></div><div><br></div><div>Which is the same vreg91, but not the right subregister. So looks like there is a liveness or liveness-update bug with the subregisters.</div><div><br></div><div>Could you please track this down to make sure we understand the problem?</div><div><br></div><div>Now, in the mean time, we may want to provide a workaround (and fix a PR to remember we added a workaround).</div><div>Your workaround is appropriate with the following fix:</div><div><div>+  // The COPY src reg and the DefMI dst reg must have the same subreg index</div><div>+  if (CopyMI->getOperand(1).getSubReg() != DefMI->getOperand(0).getSubReg())</div><div>+    return false;</div></div><div><br></div><div>I.e., instead of checking the sub register of CopyDstOperand, you have to check the sub register of copy *src* operand (like you said in your comment), i.e., 1 instead of 0.</div><div><br></div><div>Thanks,</div><div><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica;  font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">-Quentin</div>

</div>
<br><div><div>On Apr 16, 2014, at 3:13 PM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br><br>This patch fixes a bug in the register coalescer where it was incorrectly<br>rematerializing instructions that define sub-regs.<br><br>I've also attached the R600 patch which uncovers this bug.<br><br>Please Review.<br><br>-Tom<br><span><0001-RegisterCoalescer-Fix-bug-when-rematerializing-insts.patch></span><span><0002-R600-SI-Improve-chances-of-rematerializing-during-re.patch></span>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></div></body></html>