fix a bug where we thought arguments were constants :(
[oota-llvm.git] / lib / Transforms / Scalar / LoopStrengthReduce.cpp
index 95c1850089ff1dd4619a723e469ba4a44e0bc633..6c0290ae8c716c76275115be72a8091d3001ebcb 100644 (file)
@@ -154,15 +154,19 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L,
       inc_op_vector.push_back(ConstantInt::get(Ty, 1));
       indvar = op;
       break;
-    } else if (isa<Constant>(operand) || isa<Argument>(operand)) {
+    } else if (isa<Argument>(operand)) {
+      pre_op_vector.push_back(operand);
+      AllConstantOperands = false;
+    } else if (isa<Constant>(operand)) {
       pre_op_vector.push_back(operand);
     } else if (Instruction *inst = dyn_cast<Instruction>(operand)) {
       if (!DS->dominates(inst, Preheader->getTerminator()))
         return;
       pre_op_vector.push_back(operand);
       AllConstantOperands = false;
-    } else
-      return;
+    } else {
+      return;  // Cannot handle this.
+    }
     Cache = Cache->get(operand);
   }
   assert(indvar > 0 && "Indvar used by GEP not found in operand list");