<div dir="ltr"><div>The issue is we did not have the proper store instruction in isStoreToStack (was defaulting to %noreg) so the eliminateRedundantSpills was unable to recognize similar spills with like regs/address.</div><div><br></div><div>Thanks Quentin.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 14, 2016 at 1:10 PM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="-ms-word-wrap: break-word;"><div>Hi Ryan,</div><div><br></div>Could you attach the test case to reproduce?<div><br></div><div>I’d like to see the full regalloc output among other things.</div><div><br></div><div>Thanks,</div><div>-Quentin <div><div class="h5"><br><div><blockquote type="cite"><div>On Mar 14, 2016, at 9:31 AM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Quentin,</div><div><br></div><div>  Thanks for responding.</div><div><br></div><div>  Yes, you need virtual regs for SSA form.</div><div><br></div><div>  What I'm seeing as far as output are multiples of the exact same instruction (ie multiple storeRegToStack instructions). When I say 'exact same instruction', I mean literally, something like:</div><div><br></div><div>mov %r0, 0[%sp]</div><div>mov %r0, 0[%sp]</div><div>mov %r0, 0[%sp]</div><div>mov %r0, 0[%sp]</div><div><br></div><div>and so on and so on. These instructions are redundant and need to be removed/eliminated but they are making it all the way to the asm.</div><div><br></div><div>Looking at InlineSpiller.cpp in spillAroundUses it's iterating over instructions using "Reg".</div><div><br></div><div>For example, adding statements to the code I get the following sequence when iterating over the loop in spillAroundUses I mentioned above:</div><div><br></div><div>First iteration of loop:</div><div>MI: %vreg627<def> = COPY %vreg628; PTRRegs:%vreg627,%vreg628</div><div>Storing PTRRegs <a href="tel:2147484276" target="_blank" value="+12147484276">2147484276</a></div><div><br></div><div>Second iteration of loop:</div><div><div>MI: %vreg627<def> = COPY %vreg628; PTRRegs:%vreg627,%vreg628</div><div>Storing PTRRegs <a href="tel:2147484276" target="_blank" value="+12147484276">2147484276</a></div><div><br></div><div>Third iteration of loop:</div><div>MI: %vreg628<def> = COPY %vreg627; PTRRegs:%vreg628,%vreg627</div><div><br></div><div>Given this, I will get TWO 'mov' instructions In the same that do the same thing (ie, there are two "Storing PTRRegs above", like:</div><div><br></div><div>mov %b1, 0[%sp]</div><div>mov %b1, 0[%sp]</div><div><br></div><div>The code is calling hoistSpill which is calling storeRegToStack and then marking the MI Operand as dead but never checking if it's dead in subsequent iterations. Also, the MRI.reg_bundle seem to be made of copies, so the 'dead' doesn't carry over between iterations anyways.</div><div><br></div><div>So I'm not sure if:</div><div>1) The dead check should be added in the loop.</div><div>2) The multiple COPY instructions should not have been generated in the first place.</div><div><br></div><div>Thank you, your time is appreciated. If this doesn't make sense I can try and elaborate.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 14, 2016 at 12:17 PM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div style="-ms-word-wrap: break-word;">Hi Ryan,<div><br></div><div><br><div><span><blockquote type="cite"><div>On Mar 14, 2016, at 7:49 AM, Ryan Taylor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr"><div>I looked at this again and it appears that while spillAroundUses sets the register as 'dead', there is no checking to see if it's dead in subsequent iterations of the bundle loop. </div><div><br></div><div>Is this intentional?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 7, 2016 at 3:28 PM, Ryan Taylor <span dir="ltr"><<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div>Looks like spillAroundUses is spilling multiple duplicate copies to the stack, for example, with some regs we get 1 storeRegToStack call, for others we get multiple (2-6+) and then these instructions are never eliminated.</div><div><br></div><div>Looking at spillAroundUses it looks like multiple duplicate COPYs are being generated, why? One for each use?</div></div></blockquote></div></div></div></blockquote><div><br></div></span><div>We need a new virtual register for each use to have an independent coloring for each of them.</div><div>If it is not what you are seeing, I think I would need more information to help you.</div><div>For instance, the machine representation you have before and after spilling and why this is not appropriate.</div><div><br></div><div>Cheers,</div><div>-Quentin</div><br><blockquote type="cite"><div><span><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div><br></div><div>The reg_bundle holds these multiple copies so that we are iterating over the same exact COPY instructions multiple times, even though each one hits the same spot in the function:</div><div><br></div><div>if (hoistSpill(OldLI, MI)) {</div><div>     MI->getOperand(0).setIsDead();</div><div>     DeadDefs.push_back(MI);</div><div>     continue;</div><div>}</div><div><br></div><div>Even when I add a check:</div><div><br></div><div>if (MI->getOperand(0)->isDead())</div><div>    continue;</div><div><br></div><div>This never checks to true, on the second, third, fourth, etc duplicate.</div><div><br></div><div>Not sure what I'm missing? Can someone give me a brief description of why these multiple COPYs are being written out (storeRegToStack is being called)?</div><div><br></div><div>Thanks.</div><div><br></div></div>
</blockquote></div><br></div></span>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>