Throttle back indvar substitution from creating multiplies in loops. This is bad...
authorChris Lattner <sabre@nondot.org>
Mon, 26 Jul 2004 02:47:12 +0000 (02:47 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 26 Jul 2004 02:47:12 +0000 (02:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15227 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/IndVarSimplify.cpp

index 5c4c63be5ba166d4de757c49a63a02348f6b86fd..7c1f1161f59f96cca49898557ec2e544231143d3 100644 (file)
@@ -607,9 +607,9 @@ void IndVarSimplify::runOnLoop(Loop *L) {
         // 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));
+        if (SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(SCEV))
+          if (AR->getNumOperands() == 2 && isa<SCEVConstant>(AR->getOperand(1)))
+            IndVars.push_back(std::make_pair(PN, SCEV));
     }
 
   // If there are no induction variables in the loop, there is nothing more to