[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
+ // insert a trip count check and skip the peeled loop if necessary.
+ if (!SE->isKnownPredicate(CmpInst::ICMP_UGT, BTC,
----------------
preames wrote:
UGT -> NE
https://github.com/llvm/llvm-project/pull/140792
More information about the llvm-commits
mailing list