[llvm] [LoopPeel] Remove known trip count restriction when peeling last. (PR #140792)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 14:58:39 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);
----------------
fhahn wrote:
The new phi is placed in a different block (InsertTop, which is the predecessor of the header of the peeled iteration. It seems cleaner to create a new phi, but I could also move the existing phis and re-set their values if preferred.
https://github.com/llvm/llvm-project/pull/140792
More information about the llvm-commits
mailing list