From cf8f7878ebba0d19aa2c5e7f3b7f1a578996f3d9 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 17 May 2019 02:18:03 +0000 Subject: [PATCH] [LFTR] Strengthen assertions in genLoopLimit [NFCI] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360978 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/IndVarSimplify.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 8465ad7db5e..0542eca0e78 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -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(SE->getSCEV(IndVar)); - assert(AR && AR->getLoop() == L && AR->isAffine() && "bad loop counter"); + assert(isLoopCounter(IndVar, L, SE)); + const SCEVAddRecExpr *AR = cast(SE->getSCEV(IndVar)); const SCEV *IVInit = AR->getStart(); // IVInit may be a pointer while IVCount is an integer when FindLoopCounter @@ -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. -- 2.50.1