[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


================
@@ -912,10 +909,19 @@ static void cloneLoopBlocks(
   if (PeelLast) {
     // For the last iteration, we use the value from the latch of the original
     // loop directly.
+    //
+    IRBuilder<> B(InsertTop->getTerminator());
     for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
       PHINode *NewPHI = cast<PHINode>(VMap[&*I]);
-      VMap[&*I] = NewPHI->getIncomingValueForBlock(Latch);
+      PHINode *PN = B.CreatePHI(NewPHI->getType(), 2);
----------------
preames wrote:

Style only: If we've already cloned and created a new phi, why create a new one rather than just replacing one edge?

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


More information about the llvm-commits mailing list