[llvm] [SCEVExpander] Relax hoisting condition for AddRec start (PR #75916)

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 10:15:15 PST 2023


================
@@ -980,11 +980,14 @@ SCEVExpander::getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
   PostIncLoopSet SavedPostIncLoops = PostIncLoops;
   PostIncLoops.clear();
 
-  // Expand code for the start value into the loop preheader.
-  assert(L->getLoopPreheader() &&
-         "Can't expand add recurrences without a loop preheader!");
-  Value *StartV =
-      expand(Normalized->getStart(), L->getLoopPreheader()->getTerminator());
+  // Expand code for the start value into the loop predecessor. The loop is not
+  // necessarily in Loop Simplify Form, so assert it's legal to do so.
+  auto *LP = L->getLoopPredecessor();
----------------
sanjoy wrote:

Is `LP` guaranteed to dominate the loop body?

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


More information about the llvm-commits mailing list