Skip to content

Commit

Permalink
[LFTR] Strengthen assertions in genLoopLimit [NFCI]
Browse files Browse the repository at this point in the history
llvm-svn: 360978
  • Loading branch information
preames committed May 17, 2019
1 parent f51dc8d commit a74d654
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Expand Up @@ -2263,8 +2263,8 @@ static PHINode *FindLoopCounter(Loop *L, const SCEV *BECount,
/// is taken IVCount times.
static Value *genLoopLimit(PHINode *IndVar, const SCEV *IVCount, Loop *L,
SCEVExpander &Rewriter, ScalarEvolution *SE) {
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(IndVar));
assert(AR && AR->getLoop() == L && AR->isAffine() && "bad loop counter");
assert(isLoopCounter(IndVar, L, SE));
const SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(SE->getSCEV(IndVar));
const SCEV *IVInit = AR->getStart();

// IVInit may be a pointer while IVCount is an integer when FindLoopCounter
Expand Down Expand Up @@ -2311,13 +2311,13 @@ static Value *genLoopLimit(PHINode *IndVar, const SCEV *IVCount, Loop *L,
// IVInit integer and IVCount pointer would only occur if a canonical IV
// were generated on top of case #2, which is not expected.

assert(AR->getStepRecurrence(*SE)->isOne() && "only handles unit stride");
const SCEV *IVLimit = nullptr;
// For unit stride, IVCount = Start + BECount with 2's complement overflow.
// For non-zero Start, compute IVCount here.
if (AR->getStart()->isZero())
IVLimit = IVCount;
else {
assert(AR->getStepRecurrence(*SE)->isOne() && "only handles unit stride");
const SCEV *IVInit = AR->getStart();

// For integer IVs, truncate the IV before computing IVInit + BECount.
Expand Down

0 comments on commit a74d654

Please sign in to comment.