[llvm] r360978 - [LFTR] Strengthen assertions in genLoopLimit [NFCI]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 19:18:03 PDT 2019


Author: reames
Date: Thu May 16 19:18:03 2019
New Revision: 360978

URL: http://llvm.org/viewvc/llvm-project?rev=360978&view=rev
Log:
[LFTR] Strengthen assertions in genLoopLimit [NFCI]


Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=360978&r1=360977&r2=360978&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu May 16 19:18:03 2019
@@ -2263,8 +2263,8 @@ static PHINode *FindLoopCounter(Loop *L,
 /// 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
@@ -2311,13 +2311,13 @@ static Value *genLoopLimit(PHINode *IndV
     // 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.




More information about the llvm-commits mailing list