<div dir="ltr"> Hi Arthur,<div><br></div><div>There are significant amounts of code that we added internally to LoopUnswitch. I presume we will be able to move that to SimpleUnswitch, but in the interest of time we thought of porting LoopUnswitch first.</div><div><br></div><div>Regards,</div><div>Raghesh</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>------------------------------</div><div>Raghesh Aloor</div><div>AMD India Pvt. Ltd.</div><div>Bengaluru.</div><div>------------------------------</div></div></div></div></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 8, 2021 at 12:10 PM Arthur Eubanks <<a href="mailto:aeubanks@google.com">aeubanks@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">The new PM's equivalent of LoopUnswitch is the (not super well named) SimpleLoopUnswitch. Is there something specific that SimpleLoopUnswitch doesn't handle?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 7, 2021 at 11:36 PM raghesh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div>Though the LoopUnswitch pass was not ported to the new pass manager by community,  we internally at AMD are in need to do that. While doing this we are facing issues to have a counterpart for the cloneLoop function, the body of which is given below.</div><div><br></div><div><i>Loop *llvm::cloneLoop(Loop *L, Loop *PL, ValueToValueMapTy &VM,<br>                      LoopInfo *LI, LPPassManager *LPM) {<br>  Loop &New = *LI->AllocateLoop();<br>  if (PL)<br>    PL->addChildLoop(&New);<br>  else<br>    LI->addTopLevelLoop(&New);<br><br> <b> if (LPM)<br>    LPM->addLoop(New);</b><br><br>  // Add all of the blocks in L to the new loop.<br>  for (Loop::block_iterator I = L->block_begin(), E = L->block_end();<br>       I != E; ++I)<br>    if (LI->getLoopFor(*I) == L)<br>      New.addBasicBlockToLoop(cast<BasicBlock>(VM[*I]), *LI);<br><br>  // Add all of the subloops to the new loop.<br>  for (Loop *I : *L)<br>    cloneLoop(I, &New, VM, LI, LPM);<br><br>  return &New;<br>}</i></div><div><i><br></i></div><div>In the new pass manager flow, we are trying to use LPMUpdater's addSiblingLoops in place of addLoop, which will be invoked only for the top level loop (loop to be unswitched). According to the comments given in AddSiblingLoops the loops nested inside will be traversed by the pass manager anyway. In that assumption we are not adding the subloops. With this we are facing assertion failures further. </div><div><br></div><div>We also tried capturing all the newly created loops and adding it towards the end of the LoopUnswitch pass, as done in the SimpleLoopUnswitch pass. That also did not help. </div><div><br></div><div>Another approach we tried is not to add the cloned loops at all to the pass manager.. This worked  but not sure about its implications. We might miss further optimization opportunities on these loops.</div><div><br></div><div>It would be a great help if someone could point out the right way to go about it.</div><div><br></div><div>Regards,</div><div>Raghesh<br><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>------------------------------</div><div>Raghesh Aloor</div><div>AMD India Pvt. Ltd.</div><div>Bengaluru.</div><div>------------------------------</div></div></div></div></div></div></div></div></div></div>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>