diff options
author | Philip Reames <listmail@philipreames.com> | 2019-06-19 20:45:57 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-06-19 20:45:57 +0000 |
commit | ce53e2226cc41ea86a6aeb3743fa2e4598d4db93 (patch) | |
tree | 8f88658ba0cea910822faf2095fa2f8ff0f6f892 /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | |
parent | 4d000d24889670bb433eb3379e8936c6fb1ab615 (diff) | |
download | bcm5719-llvm-ce53e2226cc41ea86a6aeb3743fa2e4598d4db93.tar.gz bcm5719-llvm-ce53e2226cc41ea86a6aeb3743fa2e4598d4db93.zip |
[LFTR] Stylistic cleanup as suggested in last review comment of D62939 [NFC]
(Resumbit of r363292 which was reverted along w/an earlier patch)
llvm-svn: 363877
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 14f80fa316f..969ad50e96d 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -2388,12 +2388,15 @@ bool IndVarSimplify:: linearFunctionTestReplace(Loop *L, BasicBlock *ExitingBB, const SCEV *ExitCount, PHINode *IndVar, SCEVExpander &Rewriter) { + assert(L->getLoopLatch() && "Loop no longer in simplified form?"); + assert(isLoopCounter(IndVar, L, SE)); + Instruction * const IncVar = + cast<Instruction>(IndVar->getIncomingValueForBlock(L->getLoopLatch())); + // Initialize CmpIndVar and IVCount to their preincremented values. Value *CmpIndVar = IndVar; const SCEV *IVCount = ExitCount; - 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. @@ -2404,14 +2407,12 @@ 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())); if (ICmpInst *LoopTest = getLoopTest(L, ExitingBB)) - SafeToPostInc = LoopTest->getOperand(0) == Inc || - LoopTest->getOperand(1) == Inc; + SafeToPostInc = LoopTest->getOperand(0) == IncVar || + LoopTest->getOperand(1) == IncVar; if (!SafeToPostInc) SafeToPostInc = - mustExecuteUBIfPoisonOnPathTo(Inc, ExitingBB->getTerminator(), DT); + mustExecuteUBIfPoisonOnPathTo(IncVar, ExitingBB->getTerminator(), DT); } if (SafeToPostInc) { // Add one to the "backedge-taken" count to get the trip count. @@ -2422,7 +2423,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; } } @@ -2438,7 +2439,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()) |