Skip to content

Commit f98bdd9

Browse files
committed
Reapply "[LoopPeel] Remove known trip count restriction when peeling last. (#140792)"
This reverts commit 5804545. The recommitted version contains an extra check to not peel if the latch exit is controlled by a pointer induction. Original message: Remove the restriction that the loop must be known to execute at least 2 iterations when peeling the last iteration. If we cannot prove at least 2 iterations are executed, a check and branch to skip the peeled loop is inserted. PR: #140792
1 parent 5584020 commit f98bdd9

File tree

7 files changed

+157
-48
lines changed

7 files changed

+157
-48
lines changed

llvm/include/llvm/Transforms/Utils/LoopPeel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ gatherPeelingPreferences(Loop *L, ScalarEvolution &SE,
4444
void computePeelCount(Loop *L, unsigned LoopSize,
4545
TargetTransformInfo::PeelingPreferences &PP,
4646
unsigned TripCount, DominatorTree &DT,
47-
ScalarEvolution &SE, AssumptionCache *AC = nullptr,
47+
ScalarEvolution &SE, const TargetTransformInfo &TTI,
48+
AssumptionCache *AC = nullptr,
4849
unsigned Threshold = UINT_MAX);
4950

5051
} // end namespace llvm

llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ bool llvm::computeUnrollCount(
10141014
}
10151015

10161016
// 5th priority is loop peeling.
1017-
computePeelCount(L, LoopSize, PP, TripCount, DT, SE, AC, UP.Threshold);
1017+
computePeelCount(L, LoopSize, PP, TripCount, DT, SE, TTI, AC, UP.Threshold);
10181018
if (PP.PeelCount) {
10191019
UP.Runtime = false;
10201020
UP.Count = 1;

llvm/lib/Transforms/Utils/LoopPeel.cpp

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "llvm/Transforms/Utils/Cloning.h"
3939
#include "llvm/Transforms/Utils/LoopSimplify.h"
4040
#include "llvm/Transforms/Utils/LoopUtils.h"
41+
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
4142
#include "llvm/Transforms/Utils/ValueMapper.h"
4243
#include <algorithm>
4344
#include <cassert>
@@ -330,11 +331,7 @@ static unsigned peelToTurnInvariantLoadsDerefencebale(Loop &L,
330331

331332
bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) {
332333
const SCEV *BTC = SE.getBackedgeTakenCount(&L);
333-
// The loop must execute at least 2 iterations to guarantee that peeled
334-
// iteration executes.
335-
// TODO: Add checks during codegen.
336-
if (isa<SCEVCouldNotCompute>(BTC) ||
337-
!SE.isKnownPredicate(CmpInst::ICMP_UGT, BTC, SE.getZero(BTC->getType())))
334+
if (isa<SCEVCouldNotCompute>(BTC))
338335
return false;
339336

340337
// Check if the exit condition of the loop can be adjusted by the peeling
@@ -354,6 +351,7 @@ bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) {
354351
m_BasicBlock(Succ1), m_BasicBlock(Succ2))) &&
355352
((Pred == CmpInst::ICMP_EQ && Succ2 == L.getHeader()) ||
356353
(Pred == CmpInst::ICMP_NE && Succ1 == L.getHeader())) &&
354+
Bound->getType()->isIntegerTy() &&
357355
SE.isLoopInvariant(SE.getSCEV(Bound), &L) &&
358356
match(SE.getSCEV(Inc),
359357
m_scev_AffineAddRec(m_SCEV(), m_scev_One(), m_SpecificLoop(&L)));
@@ -364,12 +362,18 @@ bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) {
364362
/// is known at the second-to-last.
365363
static bool shouldPeelLastIteration(Loop &L, CmpPredicate Pred,
366364
const SCEVAddRecExpr *LeftAR,
367-
const SCEV *RightSCEV,
368-
ScalarEvolution &SE) {
365+
const SCEV *RightSCEV, ScalarEvolution &SE,
366+
const TargetTransformInfo &TTI) {
369367
if (!canPeelLastIteration(L, SE))
370368
return false;
371369

372370
const SCEV *BTC = SE.getBackedgeTakenCount(&L);
371+
SCEVExpander Expander(SE, L.getHeader()->getDataLayout(), "loop-peel");
372+
if (!SE.isKnownNonZero(BTC) &&
373+
Expander.isHighCostExpansion(BTC, &L, SCEVCheapExpansionBudget, &TTI,
374+
L.getLoopPredecessor()->getTerminator()))
375+
return false;
376+
373377
const SCEV *ValAtLastIter = LeftAR->evaluateAtIteration(BTC, SE);
374378
const SCEV *ValAtSecondToLastIter = LeftAR->evaluateAtIteration(
375379
SE.getMinusSCEV(BTC, SE.getOne(BTC->getType())), SE);
@@ -391,7 +395,8 @@ static bool shouldPeelLastIteration(Loop &L, CmpPredicate Pred,
391395
// ..
392396
// }
393397
static std::pair<unsigned, unsigned>
394-
countToEliminateCompares(Loop &L, unsigned MaxPeelCount, ScalarEvolution &SE) {
398+
countToEliminateCompares(Loop &L, unsigned MaxPeelCount, ScalarEvolution &SE,
399+
const TargetTransformInfo &TTI) {
395400
assert(L.isLoopSimplifyForm() && "Loop needs to be in loop simplify form");
396401
unsigned DesiredPeelCount = 0;
397402
unsigned DesiredPeelCountLast = 0;
@@ -479,7 +484,7 @@ countToEliminateCompares(Loop &L, unsigned MaxPeelCount, ScalarEvolution &SE) {
479484
const SCEV *Step = LeftAR->getStepRecurrence(SE);
480485
if (!PeelWhilePredicateIsKnown(NewPeelCount, IterVal, RightSCEV, Step,
481486
Pred)) {
482-
if (shouldPeelLastIteration(L, Pred, LeftAR, RightSCEV, SE))
487+
if (shouldPeelLastIteration(L, Pred, LeftAR, RightSCEV, SE, TTI))
483488
DesiredPeelCountLast = 1;
484489
return;
485490
}
@@ -593,8 +598,8 @@ static bool violatesLegacyMultiExitLoopCheck(Loop *L) {
593598
void llvm::computePeelCount(Loop *L, unsigned LoopSize,
594599
TargetTransformInfo::PeelingPreferences &PP,
595600
unsigned TripCount, DominatorTree &DT,
596-
ScalarEvolution &SE, AssumptionCache *AC,
597-
unsigned Threshold) {
601+
ScalarEvolution &SE, const TargetTransformInfo &TTI,
602+
AssumptionCache *AC, unsigned Threshold) {
598603
assert(LoopSize > 0 && "Zero loop size is not allowed!");
599604
// Save the PP.PeelCount value set by the target in
600605
// TTI.getPeelingPreferences or by the flag -unroll-peel-count.
@@ -656,7 +661,7 @@ void llvm::computePeelCount(Loop *L, unsigned LoopSize,
656661
}
657662

658663
const auto &[CountToEliminateCmps, CountToEliminateCmpsLast] =
659-
countToEliminateCompares(*L, MaxPeelCount, SE);
664+
countToEliminateCompares(*L, MaxPeelCount, SE, TTI);
660665
DesiredPeelCount = std::max(DesiredPeelCount, CountToEliminateCmps);
661666

662667
if (DesiredPeelCount == 0)
@@ -822,7 +827,7 @@ static void initBranchWeights(DenseMap<Instruction *, WeightInfo> &WeightInfos,
822827
/// instructions in the last peeled-off iteration.
823828
static void cloneLoopBlocks(
824829
Loop *L, unsigned IterNumber, bool PeelLast, BasicBlock *InsertTop,
825-
BasicBlock *InsertBot,
830+
BasicBlock *InsertBot, BasicBlock *OrigPreHeader,
826831
SmallVectorImpl<std::pair<BasicBlock *, BasicBlock *>> &ExitEdges,
827832
SmallVectorImpl<BasicBlock *> &NewBlocks, LoopBlocksDFS &LoopBlocks,
828833
ValueToValueMapTy &VMap, ValueToValueMapTy &LVMap, DominatorTree *DT,
@@ -914,12 +919,22 @@ static void cloneLoopBlocks(
914919
// loop iteration. Since this copy is no longer part of the loop, we
915920
// resolve this statically:
916921
if (PeelLast) {
917-
// For the last iteration, we use the value from the latch of the original
918-
// loop directly.
922+
// For the last iteration, we introduce new phis for each header phi in
923+
// InsertTop, using the incoming value from the preheader for the original
924+
// preheader (when skipping the main loop) and the incoming value from the
925+
// latch for the latch (when continuing from the main loop).
926+
IRBuilder<> B(InsertTop, InsertTop->getFirstNonPHIIt());
919927
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
920928
PHINode *NewPHI = cast<PHINode>(VMap[&*I]);
921-
VMap[&*I] = NewPHI->getIncomingValueForBlock(Latch);
929+
PHINode *PN = B.CreatePHI(NewPHI->getType(), 2);
922930
NewPHI->eraseFromParent();
931+
if (OrigPreHeader)
932+
PN->addIncoming(cast<PHINode>(&*I)->getIncomingValueForBlock(PreHeader),
933+
OrigPreHeader);
934+
935+
PN->addIncoming(cast<PHINode>(&*I)->getIncomingValueForBlock(Latch),
936+
Latch);
937+
VMap[&*I] = PN;
923938
}
924939
} else {
925940
// For the first iteration, we use the value from the preheader directly.
@@ -1053,7 +1068,7 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
10531068
// Set up all the necessary basic blocks.
10541069
BasicBlock *InsertTop;
10551070
BasicBlock *InsertBot;
1056-
BasicBlock *NewPreHeader;
1071+
BasicBlock *NewPreHeader = nullptr;
10571072
DenseMap<Instruction *, Value *> ExitValues;
10581073
if (PeelLast) {
10591074
// It is convenient to split the single exit block from the latch the
@@ -1084,11 +1099,34 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
10841099
for (PHINode &P : Exit->phis())
10851100
ExitValues[&P] = P.getIncomingValueForBlock(Latch);
10861101

1102+
const SCEV *BTC = SE->getBackedgeTakenCount(L);
1103+
10871104
InsertTop = SplitEdge(Latch, Exit, &DT, LI);
10881105
InsertBot = SplitBlock(InsertTop, InsertTop->getTerminator(), &DT, LI);
10891106

10901107
InsertTop->setName(Exit->getName() + ".peel.begin");
10911108
InsertBot->setName(Exit->getName() + ".peel.next");
1109+
NewPreHeader = nullptr;
1110+
1111+
// If the original loop may only execute a single iteration we need to
1112+
// insert a trip count check and skip the original loop with the last
1113+
// iteration peeled off if necessary.
1114+
if (!SE->isKnownNonZero(BTC)) {
1115+
NewPreHeader = SplitEdge(PreHeader, Header, &DT, LI);
1116+
SCEVExpander Expander(*SE, Latch->getDataLayout(), "loop-peel");
1117+
1118+
BranchInst *PreHeaderBR = cast<BranchInst>(PreHeader->getTerminator());
1119+
Value *BTCValue =
1120+
Expander.expandCodeFor(BTC, BTC->getType(), PreHeaderBR);
1121+
IRBuilder<> B(PreHeaderBR);
1122+
Value *Cond =
1123+
B.CreateICmpNE(BTCValue, ConstantInt::get(BTCValue->getType(), 0));
1124+
B.CreateCondBr(Cond, NewPreHeader, InsertTop);
1125+
PreHeaderBR->eraseFromParent();
1126+
1127+
// PreHeader now dominates InsertTop.
1128+
DT.changeImmediateDominator(InsertTop, PreHeader);
1129+
}
10921130
} else {
10931131
// It is convenient to split the preheader into 3 parts - two blocks to
10941132
// anchor the peeled copy of the loop body, and a new preheader for the
@@ -1162,8 +1200,9 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
11621200
for (unsigned Iter = 0; Iter < PeelCount; ++Iter) {
11631201
SmallVector<BasicBlock *, 8> NewBlocks;
11641202

1165-
cloneLoopBlocks(L, Iter, PeelLast, InsertTop, InsertBot, ExitEdges,
1166-
NewBlocks, LoopBlocks, VMap, LVMap, &DT, LI,
1203+
cloneLoopBlocks(L, Iter, PeelLast, InsertTop, InsertBot,
1204+
NewPreHeader ? PreHeader : nullptr, ExitEdges, NewBlocks,
1205+
LoopBlocks, VMap, LVMap, &DT, LI,
11671206
LoopLocalNoAliasDeclScopes, *SE);
11681207

11691208
// Remap to use values from the current iteration instead of the
@@ -1216,9 +1255,11 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, bool PeelLast, LoopInfo *LI,
12161255

12171256
if (PeelLast) {
12181257
// Now adjust users of the original exit values by replacing them with the
1219-
// exit value from the peeled iteration.
1220-
for (const auto &[P, E] : ExitValues)
1258+
// exit value from the peeled iteration and remove them.
1259+
for (const auto &[P, E] : ExitValues) {
12211260
P->replaceAllUsesWith(isa<Constant>(E) ? E : &*VMap.lookup(E));
1261+
P->eraseFromParent();
1262+
}
12221263
formLCSSA(*L, DT, LI, SE);
12231264
} else {
12241265
// Now adjust the phi nodes in the loop header to get their initial values

llvm/test/Transforms/LoopUnroll/peel-last-iteration-expansion-cost.ll

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,41 @@ define i32 @test_expansion_cost_2(i32 %start, i32 %end) {
2525
; BUDGET3-SAME: i32 [[START:%.*]], i32 [[END:%.*]]) {
2626
; BUDGET3-NEXT: [[ENTRY:.*]]:
2727
; BUDGET3-NEXT: [[SUB:%.*]] = add i32 [[END]], -1
28+
; BUDGET3-NEXT: [[TMP0:%.*]] = sub i32 [[SUB]], [[START]]
29+
; BUDGET3-NEXT: [[TMP1:%.*]] = icmp ne i32 [[TMP0]], 0
30+
; BUDGET3-NEXT: br i1 [[TMP1]], label %[[ENTRY_SPLIT:.*]], label %[[EXIT_PEEL_BEGIN:.*]]
31+
; BUDGET3: [[ENTRY_SPLIT]]:
2832
; BUDGET3-NEXT: br label %[[LOOP_HEADER:.*]]
2933
; BUDGET3: [[LOOP_HEADER]]:
30-
; BUDGET3-NEXT: [[TMP3:%.*]] = phi i32 [ [[START]], %[[ENTRY]] ], [ [[IV_NEXT_PEEL:%.*]], %[[LOOP_LATCH:.*]] ]
31-
; BUDGET3-NEXT: [[C_PEEL:%.*]] = icmp eq i32 [[TMP3]], [[SUB]]
32-
; BUDGET3-NEXT: br i1 [[C_PEEL]], label %[[THEN:.*]], label %[[LOOP_LATCH]]
34+
; BUDGET3-NEXT: [[IV:%.*]] = phi i32 [ [[START]], %[[ENTRY_SPLIT]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
35+
; BUDGET3-NEXT: [[C:%.*]] = icmp eq i32 [[IV]], [[SUB]]
36+
; BUDGET3-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[LOOP_LATCH]]
3337
; BUDGET3: [[THEN]]:
3438
; BUDGET3-NEXT: br label %[[LOOP_LATCH]]
3539
; BUDGET3: [[LOOP_LATCH]]:
36-
; BUDGET3-NEXT: [[IV_NEXT_PEEL]] = add nsw i32 [[TMP3]], 1
40+
; BUDGET3-NEXT: [[IV_NEXT]] = add nsw i32 [[IV]], 1
41+
; BUDGET3-NEXT: [[TMP2:%.*]] = sub i32 [[END]], 1
42+
; BUDGET3-NEXT: [[EC:%.*]] = icmp eq i32 [[IV_NEXT]], [[TMP2]]
43+
; BUDGET3-NEXT: br i1 [[EC]], label %[[EXIT_PEEL_BEGIN_LOOPEXIT:.*]], label %[[LOOP_HEADER]], !llvm.loop [[LOOP0:![0-9]+]]
44+
; BUDGET3: [[EXIT_PEEL_BEGIN_LOOPEXIT]]:
45+
; BUDGET3-NEXT: [[DOTPH:%.*]] = phi i32 [ [[IV_NEXT]], %[[LOOP_LATCH]] ]
46+
; BUDGET3-NEXT: br label %[[EXIT_PEEL_BEGIN]]
47+
; BUDGET3: [[EXIT_PEEL_BEGIN]]:
48+
; BUDGET3-NEXT: [[TMP3:%.*]] = phi i32 [ [[START]], %[[ENTRY]] ], [ [[DOTPH]], %[[EXIT_PEEL_BEGIN_LOOPEXIT]] ]
49+
; BUDGET3-NEXT: br label %[[LOOP_HEADER_PEEL:.*]]
50+
; BUDGET3: [[LOOP_HEADER_PEEL]]:
51+
; BUDGET3-NEXT: [[C_PEEL:%.*]] = icmp eq i32 [[TMP3]], [[SUB]]
52+
; BUDGET3-NEXT: br i1 [[C_PEEL]], label %[[THEN_PEEL:.*]], label %[[LOOP_LATCH_PEEL:.*]]
53+
; BUDGET3: [[THEN_PEEL]]:
54+
; BUDGET3-NEXT: br label %[[LOOP_LATCH_PEEL]]
55+
; BUDGET3: [[LOOP_LATCH_PEEL]]:
56+
; BUDGET3-NEXT: [[IV_NEXT_PEEL:%.*]] = add nsw i32 [[TMP3]], 1
3757
; BUDGET3-NEXT: [[EC_PEEL:%.*]] = icmp eq i32 [[IV_NEXT_PEEL]], [[END]]
38-
; BUDGET3-NEXT: br i1 [[EC_PEEL]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
58+
; BUDGET3-NEXT: br i1 [[EC_PEEL]], label %[[EXIT_PEEL_NEXT:.*]], label %[[EXIT_PEEL_NEXT]]
59+
; BUDGET3: [[EXIT_PEEL_NEXT]]:
60+
; BUDGET3-NEXT: br label %[[LOOP_HEADER_PEEL_NEXT:.*]]
61+
; BUDGET3: [[LOOP_HEADER_PEEL_NEXT]]:
62+
; BUDGET3-NEXT: br label %[[EXIT:.*]]
3963
; BUDGET3: [[EXIT]]:
4064
; BUDGET3-NEXT: ret i32 0
4165
;
@@ -59,3 +83,7 @@ loop.latch:
5983
exit:
6084
ret i32 0
6185
}
86+
;.
87+
; BUDGET3: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]]}
88+
; BUDGET3: [[META1]] = !{!"llvm.loop.peeled.count", i32 1}
89+
;.

llvm/test/Transforms/LoopUnroll/peel-last-iteration-with-constant-trip-count.ll

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ define i64 @peel_single_block_loop_iv_step_1() {
1313
; CHECK-NEXT: br i1 [[EC1]], label %[[LOOP]], label %[[EXIT_PEEL_BEGIN:.*]], !llvm.loop [[LOOP0:![0-9]+]]
1414
; CHECK: [[EXIT_PEEL_BEGIN]]:
1515
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT1]], %[[LOOP]] ]
16-
; CHECK-NEXT: [[IV_LCSSA:%.*]] = phi i64 [ [[IV1]], %[[LOOP]] ]
1716
; CHECK-NEXT: br label %[[LOOP_PEEL:.*]]
1817
; CHECK: [[LOOP_PEEL]]:
1918
; CHECK-NEXT: [[CMP18_NOT:%.*]] = icmp eq i64 [[IV]], 63
@@ -92,7 +91,6 @@ define i64 @peel_single_block_loop_iv_step_1_eq_pred() {
9291
; CHECK-NEXT: br i1 [[CMP_PEEL]], label %[[EXIT_PEEL_BEGIN:.*]], label %[[LOOP]], !llvm.loop [[LOOP2:![0-9]+]]
9392
; CHECK: [[EXIT_PEEL_BEGIN]]:
9493
; CHECK-NEXT: [[IV_NEXT_LCSSA:%.*]] = phi i64 [ [[IV_LCSSA]], %[[LOOP]] ]
95-
; CHECK-NEXT: [[IV_LCSSA1:%.*]] = phi i64 [ [[IV]], %[[LOOP]] ]
9694
; CHECK-NEXT: br label %[[LOOP_PEEL:.*]]
9795
; CHECK: [[LOOP_PEEL]]:
9896
; CHECK-NEXT: [[CMP_PEEL1:%.*]] = icmp eq i64 [[IV_NEXT_LCSSA]], 63
@@ -171,7 +169,6 @@ define i64 @peel_single_block_loop_iv_step_1_nested_loop() {
171169
; CHECK-NEXT: br i1 [[EC]], label %[[LOOP]], label %[[OUTER_LATCH_PEEL_BEGIN:.*]], !llvm.loop [[LOOP3:![0-9]+]]
172170
; CHECK: [[OUTER_LATCH_PEEL_BEGIN]]:
173171
; CHECK-NEXT: [[IV_NEXT_LCSSA:%.*]] = phi i64 [ [[IV_NEXT]], %[[LOOP]] ]
174-
; CHECK-NEXT: [[IV_LCSSA:%.*]] = phi i64 [ [[IV]], %[[LOOP]] ]
175172
; CHECK-NEXT: br label %[[LOOP_PEEL:.*]]
176173
; CHECK: [[LOOP_PEEL]]:
177174
; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp eq i64 [[IV_NEXT_LCSSA]], 63
@@ -237,7 +234,6 @@ define i64 @peel_multi_block_loop_iv_step_1() {
237234
; CHECK-NEXT: br i1 [[EC]], label %[[LOOP]], label %[[EXIT_PEEL_BEGIN:.*]], !llvm.loop [[LOOP4:![0-9]+]]
238235
; CHECK: [[EXIT_PEEL_BEGIN]]:
239236
; CHECK-NEXT: [[IV_NEXT_LCSSA:%.*]] = phi i64 [ [[IV_NEXT]], %[[LATCH]] ]
240-
; CHECK-NEXT: [[IV_LCSSA:%.*]] = phi i64 [ [[IV]], %[[LATCH]] ]
241237
; CHECK-NEXT: br label %[[LOOP_PEEL:.*]]
242238
; CHECK: [[LOOP_PEEL]]:
243239
; CHECK-NEXT: [[CMP_PEEL:%.*]] = icmp eq i64 [[IV_NEXT_LCSSA]], 63
@@ -365,7 +361,6 @@ define i64 @peel_single_block_loop_iv_step_1_btc_1() {
365361
; CHECK-NEXT: br i1 false, label %[[LOOP]], label %[[EXIT_PEEL_BEGIN:.*]], !llvm.loop [[LOOP5:![0-9]+]]
366362
; CHECK: [[EXIT_PEEL_BEGIN]]:
367363
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT1]], %[[LOOP]] ]
368-
; CHECK-NEXT: [[IV_LCSSA:%.*]] = phi i64 [ [[IV1]], %[[LOOP]] ]
369364
; CHECK-NEXT: br label %[[LOOP_PEEL:.*]]
370365
; CHECK: [[LOOP_PEEL]]:
371366
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[IV]], 1
@@ -483,9 +478,8 @@ define i32 @peel_loop_with_branch_and_phi_uses(ptr %x, i1 %c) {
483478
; CHECK-NEXT: [[EC1:%.*]] = icmp ne i32 [[IV_NEXT1]], 99
484479
; CHECK-NEXT: br i1 [[EC1]], label %[[LOOP_HEADER]], label %[[LOOPEXIT_PEEL_BEGIN:.*]], !llvm.loop [[LOOP6:![0-9]+]]
485480
; CHECK: [[LOOPEXIT_PEEL_BEGIN]]:
486-
; CHECK-NEXT: [[RED:%.*]] = phi i32 [ [[ADD1]], %[[LOOP_LATCH]] ]
487481
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ [[IV_NEXT1]], %[[LOOP_LATCH]] ]
488-
; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi i32 [ [[ADD1]], %[[LOOP_LATCH]] ]
482+
; CHECK-NEXT: [[RED:%.*]] = phi i32 [ [[ADD1]], %[[LOOP_LATCH]] ]
489483
; CHECK-NEXT: br label %[[LOOP_HEADER_PEEL:.*]]
490484
; CHECK: [[LOOP_HEADER_PEEL]]:
491485
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[IV]], 99

0 commit comments

Comments
 (0)