Skip to content

Commit

Permalink
[LFTR] Stylistic cleanup as suggested in last review comment of D6293…
Browse files Browse the repository at this point in the history
…9 [NFC]

llvm-svn: 363292
  • Loading branch information
preames committed Jun 13, 2019
1 parent 5bf7f81 commit 42a3fc1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Expand Up @@ -2385,12 +2385,15 @@ bool IndVarSimplify::
linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
const SCEV *BackedgeTakenCount,
PHINode *IndVar, SCEVExpander &Rewriter) {
assert(isLoopCounter(IndVar, L, SE));
assert(L->getLoopLatch() && "Loop no longer in simplified form?");
Instruction * const IncVar =
cast<Instruction>(IndVar->getIncomingValueForBlock(L->getLoopLatch()));

// Initialize CmpIndVar and IVCount to their preincremented values.
Value *CmpIndVar = IndVar;
const SCEV *IVCount = BackedgeTakenCount;

assert(L->getLoopLatch() && "Loop no longer in simplified form?");

// If the exiting block is the same as the backedge block, we prefer to
// compare against the post-incremented value, otherwise we must compare
// against the preincremented value.
Expand All @@ -2401,12 +2404,10 @@ linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
// to add a potentially UB introducing use. We need to either a) show
// the loop test we're modifying is already in post-inc form, or b) show
// that adding a use must not introduce UB.
Instruction *Inc =
cast<Instruction>(IndVar->getIncomingValueForBlock(L->getLoopLatch()));
ICmpInst *LoopTest = getLoopTest(L, ExitingBB);
SafeToPostInc = LoopTest->getOperand(0) == Inc ||
LoopTest->getOperand(1) == Inc ||
mustExecuteUBIfPoisonOnPathTo(Inc, ExitingBB->getTerminator(), DT);
SafeToPostInc = LoopTest->getOperand(0) == IncVar ||
LoopTest->getOperand(1) == IncVar ||
mustExecuteUBIfPoisonOnPathTo(IncVar, ExitingBB->getTerminator(), DT);
}
if (SafeToPostInc) {
// Add one to the "backedge-taken" count to get the trip count.
Expand All @@ -2417,7 +2418,7 @@ linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB,
// The BackedgeTaken expression contains the number of times that the
// backedge branches to the loop header. This is one less than the
// number of times the loop executes, so use the incremented indvar.
CmpIndVar = IndVar->getIncomingValueForBlock(ExitingBB);
CmpIndVar = IncVar;
}
}

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

0 comments on commit 42a3fc1

Please sign in to comment.