[llvm] [LoopUnroll] Rotate loop to make it countable for runtime unrolling (PR #146540)

Marek Sedláček via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 07:25:36 PDT 2025


================
@@ -484,8 +485,27 @@ llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
 
   assert(ULO.Count > 0);
 
-  // All these values should be taken only after peeling because they might have
-  // changed.
+  if (ULO.Runtime && SE) {
+    BasicBlock *OrigHeader = L->getHeader();
+    BranchInst *BI = dyn_cast<BranchInst>(OrigHeader->getTerminator());
+    // Rotate loop if it makes it countable (for later unrolling)
----------------
mark-sed wrote:

Fixed the wording of the comment and the debug message. Thank you.

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


More information about the llvm-commits mailing list