[llvm] [LoopPeel] Peel to make Phis loop inductions (PR #121104)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 05:47:46 PST 2025


================
@@ -190,6 +221,67 @@ PhiAnalyzer::PhiAnalyzer(const Loop &L, unsigned MaxIterations)
   assert(MaxIterations > 0 && "no peeling is allowed?");
 }
 
+// Test if \p Phi is induction variable or not. It can be checked by using SCEV,
+// but it's expensive to calculate it here. Instead, we perform the cheaper
+// checks, which cannot detect complex one but enough for some cases.
+bool PhiAnalyzer::isInductionPHI(const PHINode *Phi) const {
+  // Currently, we only support loops that consist of one basic block. In this
+  // case, the phi can become an IV if it has an incoming value from the basic
+  // block that this phi is also included.
----------------
kasuga-fj wrote:

The purpose of that is to limit the number of incoming edges from the loop to one, and your suggestion looks better to me. Thanks! (Also, your point about the English language is also very much appreciated.)

https://github.com/llvm/llvm-project/pull/121104


More information about the llvm-commits mailing list