Skip to content

Commit 42a3fc1

Browse files
committedJun 13, 2019
[LFTR] Stylistic cleanup as suggested in last review comment of D62939 [NFC]
llvm-svn: 363292
1 parent 5bf7f81 commit 42a3fc1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,12 +2385,15 @@ bool IndVarSimplify::
23852385
linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
23862386
const SCEV *BackedgeTakenCount,
23872387
PHINode *IndVar, SCEVExpander &Rewriter) {
2388+
assert(isLoopCounter(IndVar, L, SE));
2389+
assert(L->getLoopLatch() && "Loop no longer in simplified form?");
2390+
Instruction * const IncVar =
2391+
cast<Instruction>(IndVar->getIncomingValueForBlock(L->getLoopLatch()));
2392+
23882393
// Initialize CmpIndVar and IVCount to their preincremented values.
23892394
Value *CmpIndVar = IndVar;
23902395
const SCEV *IVCount = BackedgeTakenCount;
23912396

2392-
assert(L->getLoopLatch() && "Loop no longer in simplified form?");
2393-
23942397
// If the exiting block is the same as the backedge block, we prefer to
23952398
// compare against the post-incremented value, otherwise we must compare
23962399
// against the preincremented value.
@@ -2401,12 +2404,10 @@ linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
24012404
// to add a potentially UB introducing use. We need to either a) show
24022405
// the loop test we're modifying is already in post-inc form, or b) show
24032406
// that adding a use must not introduce UB.
2404-
Instruction *Inc =
2405-
cast<Instruction>(IndVar->getIncomingValueForBlock(L->getLoopLatch()));
24062407
ICmpInst *LoopTest = getLoopTest(L, ExitingBB);
2407-
SafeToPostInc = LoopTest->getOperand(0) == Inc ||
2408-
LoopTest->getOperand(1) == Inc ||
2409-
mustExecuteUBIfPoisonOnPathTo(Inc, ExitingBB->getTerminator(), DT);
2408+
SafeToPostInc = LoopTest->getOperand(0) == IncVar ||
2409+
LoopTest->getOperand(1) == IncVar ||
2410+
mustExecuteUBIfPoisonOnPathTo(IncVar, ExitingBB->getTerminator(), DT);
24102411
}
24112412
if (SafeToPostInc) {
24122413
// Add one to the "backedge-taken" count to get the trip count.
@@ -2417,7 +2418,7 @@ linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
24172418
// The BackedgeTaken expression contains the number of times that the
24182419
// backedge branches to the loop header. This is one less than the
24192420
// number of times the loop executes, so use the incremented indvar.
2420-
CmpIndVar = IndVar->getIncomingValueForBlock(ExitingBB);
2421+
CmpIndVar = IncVar;
24212422
}
24222423
}
24232424

@@ -2433,7 +2434,6 @@ linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
24332434
// dynamically dead IV that wraps on the first loop iteration only, which is
24342435
// not covered by the post-inc addrec. (If the new IV was not dynamically
24352436
// dead, it could not be poison on the first iteration in the first place.)
2436-
Value *IncVar = IndVar->getIncomingValueForBlock(L->getLoopLatch());
24372437
if (auto *BO = dyn_cast<BinaryOperator>(IncVar)) {
24382438
const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(SE->getSCEV(IncVar));
24392439
if (BO->hasNoUnsignedWrap())

0 commit comments

Comments
 (0)
Please sign in to comment.