DependenceAnalysis: Don't crash if there is no constant operand.

This makes the code match the comments. Resolves a crash in loop idiom (PR14219).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer
2012-10-31 09:20:38 +00:00
parent 296815dcce
commit 061938b90b
2 changed files with 29 additions and 3 deletions

View File

@ -2278,11 +2278,12 @@ bool DependenceAnalysis::gcdMIVtest(const SCEV *Src,
assert(!Constant && "Surprised to find multiple constants");
Constant = cast<SCEVConstant>(Operand);
}
else if (isa<SCEVMulExpr>(Operand)) {
else if (const SCEVMulExpr *Product = dyn_cast<SCEVMulExpr>(Operand)) {
// Search for constant operand to participate in GCD;
// If none found; return false.
const SCEVConstant *ConstOp =
getConstantPart(cast<SCEVMulExpr>(Operand));
const SCEVConstant *ConstOp = getConstantPart(Product);
if (!ConstOp)
return false;
APInt ConstOpValue = ConstOp->getValue()->getValue();
ExtraGCD = APIntOps::GreatestCommonDivisor(ExtraGCD,
ConstOpValue.abs());