Index: lib/Transforms/Scalar/IndVarSimplify.cpp =================================================================== --- lib/Transforms/Scalar/IndVarSimplify.cpp +++ lib/Transforms/Scalar/IndVarSimplify.cpp @@ -136,7 +136,9 @@ SmallVector DeadInsts; bool Changed = false; +#ifndef NDEBUG bool isValidRewrite(Value *FromVal, Value *ToVal); +#endif void handleFloatingPointIV(Loop *L, PHINode *PH); void rewriteNonIntegerIVs(Loop *L); @@ -166,10 +168,10 @@ } // end anonymous namespace +#ifndef NDEBUG /// Return true if the SCEV expansion generated by the rewriter can replace the /// original value. SCEV guarantees that it produces the same value, but the way -/// it is produced may be illegal IR. Ideally, this function will only be -/// called for verification. +/// it is produced may be illegal IR. bool IndVarSimplify::isValidRewrite(Value *FromVal, Value *ToVal) { // If an SCEV expression subsumed multiple pointers, its expansion could // reassociate the GEP changing the base pointer. This is illegal because the @@ -217,6 +219,7 @@ } return true; } +#endif /// Determine the insertion point for this user. By default, insert immediately /// before the user. SCEVExpander or LICM will hoist loop invariants out of the @@ -656,10 +659,7 @@ << '\n' << " LoopVal = " << *Inst << "\n"); - if (!isValidRewrite(Inst, ExitVal)) { - DeadInsts.push_back(ExitVal); - continue; - } + assert(isValidRewrite(Inst, ExitVal) && "Must be!"); // Collect all the candidate PHINodes to be rewritten. RewritePhiSet.emplace_back(PN, i, ExitVal, HighCost);