[PATCH] D154205: [MachineLICM] Handle subloops

JinGu Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 01:49:51 PDT 2023


jaykang10 added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineLICM.cpp:321
+  // Add loop to worklist
+  Worklist.push_back(Loop);
+
----------------
wxiao3 wrote:
> 2 questions:
> 1) why we don't require that the outer-most loop that has a unique predecessor?
> 2) can we push the innermost loops into the worklist first?
Thanks for questions.
> 1) why we don't require that the outer-most loop that has a unique predecessor?
As you can see, current implementation handles inner loops when outmost loop does not have unique predecessor. If loops have preheader, I think we can hoist loop invariant code into the preheader. The `HoistOutOfLoop` function checks it so I think we do not need to check the outer-most loop that has a unique predecessor.
> 2) can we push the innermost loops into the worklist first?
We use `Worklist.pop_back_val()` and it means we handles last element of worklist first. In order to handle inner-most loop first, the inner-most loop is pushed into last element of the worklist.
If you feel something wrong, please let me know.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154205/new/

https://reviews.llvm.org/D154205



More information about the llvm-commits mailing list