diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-31 09:20:38 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-10-31 09:20:38 +0000 |
commit | 061938b90b1addc3c3269bdbfeae1029f0c05a43 (patch) | |
tree | b91e5255365c70dd69bdee448b3f4c916d0a19c4 /lib/Analysis | |
parent | 296815dccee4f5392855c829b8a9e4a661b83a42 (diff) |
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
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/DependenceAnalysis.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Analysis/DependenceAnalysis.cpp b/lib/Analysis/DependenceAnalysis.cpp index f97f0f2de6..c1321b63f2 100644 --- a/lib/Analysis/DependenceAnalysis.cpp +++ b/lib/Analysis/DependenceAnalysis.cpp @@ -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()); |