<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Ryan,</div><div class=""><br class=""></div>Could you attach the test case to reproduce?<div class=""><br class=""></div><div class="">I’d like to see the full regalloc output among other things.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-Quentin <br class=""><div><blockquote type="cite" class=""><div class="">On Mar 14, 2016, at 9:31 AM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" class="">ryta1203@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Quentin,</div><div class=""><br class=""></div><div class="">  Thanks for responding.</div><div class=""><br class=""></div><div class="">  Yes, you need virtual regs for SSA form.</div><div class=""><br class=""></div><div class="">  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 class=""><br class=""></div><div class="">mov %r0, 0[%sp]</div><div class="">mov %r0, 0[%sp]</div><div class="">mov %r0, 0[%sp]</div><div class="">mov %r0, 0[%sp]</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Looking at InlineSpiller.cpp in spillAroundUses it's iterating over instructions using "Reg".</div><div class=""><br class=""></div><div class="">For example, adding statements to the code I get the following sequence when iterating over the loop in spillAroundUses I mentioned above:</div><div class=""><br class=""></div><div class="">First iteration of loop:</div><div class="">MI: %vreg627<def> = COPY %vreg628; PTRRegs:%vreg627,%vreg628</div><div class="">Storing PTRRegs 2147484276</div><div class=""><br class=""></div><div class="">Second iteration of loop:</div><div class=""><div class="">MI: %vreg627<def> = COPY %vreg628; PTRRegs:%vreg627,%vreg628</div><div class="">Storing PTRRegs 2147484276</div><div class=""><br class=""></div><div class="">Third iteration of loop:</div><div class="">MI: %vreg628<def> = COPY %vreg627; PTRRegs:%vreg628,%vreg627</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">mov %b1, 0[%sp]</div><div class="">mov %b1, 0[%sp]</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">So I'm not sure if:</div><div class="">1) The dead check should be added in the loop.</div><div class="">2) The multiple COPY instructions should not have been generated in the first place.</div><div class=""><br class=""></div><div class="">Thank you, your time is appreciated. If this doesn't make sense I can try and elaborate.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Mar 14, 2016 at 12:17 PM, Quentin Colombet <span dir="ltr" class=""><<a href="mailto:qcolombet@apple.com" target="_blank" class="">qcolombet@apple.com</a>></span> wrote:<br class=""><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="word-wrap:break-word" class="">Hi Ryan,<div class=""><br class=""></div><div class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Mar 14, 2016, at 7:49 AM, Ryan Taylor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">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 class=""><br class=""></div><div class="">Is this intentional?</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Mar 7, 2016 at 3:28 PM, Ryan Taylor <span dir="ltr" class=""><<a href="mailto:ryta1203@gmail.com" target="_blank" class="">ryta1203@gmail.com</a>></span> wrote:<br class=""><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" class=""><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div></span><div class="">We need a new virtual register for each use to have an independent coloring for each of them.</div><div class="">If it is not what you are seeing, I think I would need more information to help you.</div><div class="">For instance, the machine representation you have before and after spilling and why this is not appropriate.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Quentin</div><br class=""><blockquote type="cite" class=""><div class=""><span class=""><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" class=""><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">if (hoistSpill(OldLI, MI)) {</div><div class="">     MI->getOperand(0).setIsDead();</div><div class="">     DeadDefs.push_back(MI);</div><div class="">     continue;</div><div class="">}</div><div class=""><br class=""></div><div class="">Even when I add a check:</div><div class=""><br class=""></div><div class="">if (MI->getOperand(0)->isDead())</div><div class="">    continue;</div><div class=""><br class=""></div><div class="">This never checks to true, on the second, third, fourth, etc duplicate.</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">Thanks.</div><div class=""><br class=""></div></div>
</blockquote></div><br class=""></div></span>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>