<div dir="ltr">Hi Hal,<div><br></div><div>Thanks for your reminding. Finally I inserted InstructionSimplifier pass as barrier and committed it at r232011.</div><div><br></div><div>Cheers,</div><div>Kevin</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-03-11 20:37 GMT+08:00 Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">----- Original Message -----<br>
> From: "Kevin Qin" <<a href="mailto:kevinqindev@gmail.com">kevinqindev@gmail.com</a>><br>
</span><span class="">> To: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>><br>
> Cc: "LLVM Developers Mailing List" <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>>, "chandlerc" <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>>, "James Molloy"<br>
> <<a href="mailto:james@jamesmolloy.co.uk">james@jamesmolloy.co.uk</a>><br>
> Sent: Wednesday, March 11, 2015 5:04:49 AM<br>
> Subject: Re: [LLVMdev] How to run two loop passes non-interleaved if they are registered one by one?<br>
><br>
><br>
> Hi Hal,<br>
><br>
><br>
> James told me that in PassManagerBuilder.cpp, BarrierNoopPass is<br>
> already used for this kind of purpose(though there's also a fixme<br>
> saying it's hacking). I think it's a good idea to use this pass<br>
> here.<br>
<br>
</span>Yes and no. BarrierNoopPass is a module level pass (we use it to break out of the CGSCC pass manager), and so is overkill here. You just need a function level pass. If you're adding this near the end, it might not matter that much, however.<br>
<span class="HOEnZb"><font color="#888888"><br>
 -Hal<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
><br>
> Thanks,<br>
> Kevin<br>
><br>
><br>
> 2015-03-11 17:05 GMT+08:00 Hal Finkel < <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> > :<br>
><br>
><br>
><br>
><br>
> ----- Original Message -----<br>
> > From: "Kevin Qin" < <a href="mailto:kevinqindev@gmail.com">kevinqindev@gmail.com</a> ><br>
> > To: "LLVM Developers Mailing List" < <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a> ><br>
> > Sent: Wednesday, March 11, 2015 3:47:35 AM<br>
> > Subject: [LLVMdev] How to run two loop passes non-interleaved if<br>
> > they are registered one by one?<br>
> ><br>
> ><br>
> ><br>
> > Hi LLVM developers,<br>
> ><br>
> ><br>
> > I want to add LICM pass after loop unrolling pass in current<br>
> > optimization pipeline. Because both of them are loop passes, so if<br>
> > I<br>
> > registered them one by one, they will interleaved go through all<br>
> > loops in bottom up way within same loop pass manager. Loop unroling<br>
> > pass may create new inner loops from partial unrolling, and those<br>
> > newly created loops can be visited only if the rest of loop passes<br>
> > are finished on current loop. The problem is, this visit order may<br>
> > be not in bottom up way, but that is order is required by LICM.<br>
> ><br>
> ><br>
> > For example, the input has 2 nested loops(L1 and L2).<br>
> ><br>
> ><br>
> > for () { //L1<br>
> > for() { }//L2<br>
> > }<br>
> ><br>
> ><br>
> ><br>
> > We registered LICM pass after loop unrolling pass, so these 2<br>
> > passes<br>
> > will share the same loop pass manager. The initialized work queue<br>
> > will be (L1, L2). Loop pass manager always pops out the last<br>
> > object,<br>
> > so loop unrolling pass will visit L2 first, and then LICM pass.<br>
> > When<br>
> > L2 is visited by all passes, it will be removed from queue. At this<br>
> > stage, everything is fine.<br>
> ><br>
> ><br>
> > Next, L1 is on process, and it's partial unrolled from loop<br>
> > unrolling<br>
> > pass, and finally L3 is created.<br>
> ><br>
> ><br>
> ><br>
> > for () { //L1<br>
> > for() { }//L2<br>
> > for() { }//L3<br>
> ><br>
> > }<br>
> ><br>
> ><br>
> > Here's the problem. As LICM shared same loop pass manager will loop<br>
> > unrolling pass, then L1 will be visited by LICM. But LICM extremely<br>
> > requires a bottle up visit order, and at this moment, L1 is visited<br>
> > earlier than L3, this will cause assertion failure.<br>
> ><br>
> ><br>
> > The best solution for this is spiting two passes into different<br>
> > pass<br>
> > manager, and let them run non-interleaved. But I don't know how to<br>
> > implement this within legacy pass manager. Does anyone know how to<br>
> > do that?<br>
> ><br>
><br>
> I believe that, generically, we've needed 'barrier' passes for this<br>
> purpose. Creating a 'noop' function pass is an option. In this case,<br>
> inserting a run of instcombine (or, if that's too expensive for some<br>
> reason, instsimplify) could be reasonable. I can imagine unrolling<br>
> creating things that turn out to be loop invariant only after<br>
> simplification (especially considering that we rely on<br>
> simplification to clean up the repeated induction variable<br>
> increments, etc. after unrolling).<br>
><br>
> -Hal<br>
><br>
> ><br>
> > If you have any better solution, don't hesitate to share.<br>
> ><br>
> ><br>
> ><br>
> > --<br>
> ><br>
> ><br>
> > Thanks a lot in advance,<br>
> ><br>
> ><br>
> > Kevin Qin<br>
> > _______________________________________________<br>
> > LLVM Developers mailing list<br>
> > <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> > <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
> ><br>
><br>
> --<br>
> Hal Finkel<br>
> Assistant Computational Scientist<br>
> Leadership Computing Facility<br>
> Argonne National Laboratory<br>
><br>
><br>
><br>
><br>
> --<br>
><br>
><br>
> Best Regards,<br>
><br>
><br>
> Kevin Qin<br>
<br>
--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Best Regards,<div><br></div><div>Kevin Qin</div></div></div>
</div>