<div dir="ltr">Hi LLVM developers,<div><br></div><div>I want to add LICM pass after loop unrolling pass in current optimization pipeline. Because both of them are loop passes, so if I registered them one by one, they will interleaved go through all loops in bottom up way within same loop pass manager. Loop unroling pass may create new inner loops from partial unrolling, and those newly created loops can be visited only if the rest of loop passes are finished on current loop. The problem is, this visit order may be not in bottom up way, but that is order is required by LICM.</div><div><br></div><div>For example, the input has 2 nested loops(L1 and L2). </div><div><br></div><div>for () { //L1</div><div>  for() { }//L2</div><div>}<br></div><div><br></div><div>We registered LICM pass after loop unrolling pass, so these 2 passes will share the same loop pass manager. The initialized work queue will be (L1, L2). Loop pass manager always pops out the last object, so loop unrolling pass will visit L2 first, and then LICM pass. When L2 is visited by all passes, it will be removed from queue. At this stage, everything is fine.</div><div><br></div><div>Next, L1 is on process, and it's partial unrolled from loop unrolling pass, and finally L3 is created.</div><div><br></div><div><div>for () { //L1</div><div>  for() { }//L2</div><div>  for() { }//L3<br></div><div>}</div><div><br></div><div>Here's the problem. As LICM shared same loop pass manager will loop unrolling pass, then L1 will be visited by LICM. But LICM extremely requires a bottle up visit order, and at this moment, L1 is visited earlier than L3, this will cause assertion failure.</div><div><br></div><div>The best solution for this is spiting two passes into different pass manager, and let them run non-interleaved. But I don't know how to implement this within legacy pass manager. Does anyone know how to do that?</div><div><br></div><div>If you have any better solution, don't hesitate to share.</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Thanks a lot in advance,<div><br></div><div>Kevin Qin</div></div></div>
</div></div>