diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 56f021334b5..5c4c63be5ba 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -602,7 +602,13 @@ void IndVarSimplify::runOnLoop(Loop *L) { 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(SCEV) || + cast(SCEV)->getNumOperands() < 3) IndVars.push_back(std::make_pair(PN, SCEV)); }