[llvm] [LoopPeel] Remove known trip count restriction when peeling last. (PR #140792)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed May 21 07:24:53 PDT 2025


================
@@ -1080,11 +1086,40 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
     for (PHINode &P : Exit->phis())
       ExitValues[&P] = P.getIncomingValueForBlock(Latch);
 
+    const SCEV *BTC = SE->getBackedgeTakenCount(L);
+
     InsertTop = SplitEdge(Latch, Exit, &DT, LI);
     InsertBot = SplitBlock(InsertTop, InsertTop->getTerminator(), &DT, LI);
 
     InsertTop->setName(Exit->getName() + ".peel.begin");
     InsertBot->setName(Exit->getName() + ".peel.next");
+    NewPreHeader = nullptr;
+
+    // If the original loop may only execute a single iteration we need to
----------------
preames wrote:

Both in the comment and the description, the term "peeled loop" is ambiguous.  You mean the loop with the last iteration peeled off, not the peeled off iteration.  Can you reword a bit to make that distinction a bit more obvious?  

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


More information about the llvm-commits mailing list