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

Chris Lattner lattner at cs.uiuc.edu
Thu Jun 24 01:50:01 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

IndVarSimplify.cpp updated: 1.66 -> 1.67

---
Log message:

Two fixes.  First, stop using the ugly shouldSubstituteIndVar method.

Second, disable substitution of quadratic addrec expressions to avoid putting
multiplies in loops!


---
Diffs of the changes:  (+7 -1)

Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.66 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.67
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.66	Sun Jun 20 00:04:01 2004
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp	Thu Jun 24 01:49:18 2004
@@ -602,7 +602,13 @@
     if (PN->getType()->isInteger()) {  // FIXME: when we have fast-math, enable!
       SCEVHandle SCEV = SE->getSCEV(PN);
       if (SCEV->hasComputableLoopEvolution(L))
-        if (SE->shouldSubstituteIndVar(SCEV))  // HACK!
+        // 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.
+        if (!isa<SCEVAddRecExpr>(SCEV) || 
+            cast<SCEVAddRecExpr>(SCEV)->getNumOperands() < 3)
           IndVars.push_back(std::make_pair(PN, SCEV));
     }
 





More information about the llvm-commits mailing list