diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index c496c57836f..e31b514b2fa 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -582,18 +582,17 @@ static const PHINode *TestOrigIVForWrap(const Loop *L, // For now, only analyze loops with a constant start value, so that // we can easily determine if the start value is not a maximum value // which would wrap on the first iteration. - const Value *InitialVal = PN->getIncomingValue(IncomingEdge); - if (!isa(InitialVal)) + const ConstantInt *InitialVal = + dyn_cast(PN->getIncomingValue(IncomingEdge)); + if (!InitialVal) return 0; // The original induction variable will start at some non-max value, // it counts up by one, and the loop iterates only while it remans // less than some value in the same type. As such, it will never wrap. - if (isSigned && - !cast(InitialVal)->getValue().isMaxSignedValue()) + if (isSigned && !InitialVal->getValue().isMaxSignedValue()) NoSignedWrap = true; - else if (!isSigned && - !cast(InitialVal)->getValue().isMaxValue()) + else if (!isSigned && !InitialVal->getValue().isMaxValue()) NoUnsignedWrap = true; return PN; }