[llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 9 18:12:17 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

IndVarSimplify.cpp updated: 1.79 -> 1.80
---
Log message:

Allow indvar simplify to canonicalize ANY affine IV, not just affine IVs with
constant stride.  This implements Transforms/IndVarsSimplify/variable-stride-ivs.ll


---
Diffs of the changes:  (+8 -8)

 IndVarSimplify.cpp |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.79 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.80
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.79	Fri Jul 29 19:12:19 2005
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp	Tue Aug  9 20:12:06 2005
@@ -128,9 +128,9 @@
   unsigned PreheaderIdx = PN->getBasicBlockIndex(Preheader);
   unsigned BackedgeIdx = PreheaderIdx^1;
   if (GetElementPtrInst *GEPI =
-      dyn_cast<GetElementPtrInst>(PN->getIncomingValue(BackedgeIdx)))
+          dyn_cast<GetElementPtrInst>(PN->getIncomingValue(BackedgeIdx)))
     if (GEPI->getOperand(0) == PN) {
-      assert(GEPI->getNumOperands() == 2 && "GEP types must mismatch!");
+      assert(GEPI->getNumOperands() == 2 && "GEP types must match!");
 
       // Okay, we found a pointer recurrence.  Transform this pointer
       // recurrence into an integer recurrence.  Compute the value that gets
@@ -407,13 +407,13 @@
     if (PN->getType()->isInteger()) {  // FIXME: when we have fast-math, enable!
       SCEVHandle SCEV = SE->getSCEV(PN);
       if (SCEV->hasComputableLoopEvolution(L))
-        // FIXME: Without a strength reduction pass, it is an extremely bad idea
-        // to indvar substitute anything more complex than a linear induction
-        // variable.  Doing so will put expensive multiply instructions inside
-        // of the loop.  For now just disable indvar subst on anything more
-        // complex than a linear addrec.
+        // FIXME: It is an extremely bad idea to indvar substitute anything more
+        // complex than affine induction variables.  Doing so will put expensive
+        // polynomial evaluations inside of the loop, and the str reduction pass
+        // currently can only reduce affine polynomials.  For now just disable
+        // indvar subst on anything more complex than an affine addrec.
         if (SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEV))
-          if (AR->getNumOperands() == 2 && isa<SCEVConstant>(AR->getOperand(1)))
+          if (AR->isAffine())
             IndVars.push_back(std::make_pair(PN, SCEV));
     }
   }






More information about the llvm-commits mailing list