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 | 24c643b6dea6811563c371fd1a8601380cafa257 (patch) | |
tree | 7bec1defbe7665d9c760c81344b4fd76f6eb6f8e /llvm/lib | |
parent | 2f728a918552d156398a40baa5dd0baa1e53c1b3 (diff) | |
download | bcm5719-llvm-24c643b6dea6811563c371fd1a8601380cafa257.tar.gz bcm5719-llvm-24c643b6dea6811563c371fd1a8601380cafa257.zip |
DependenceAnalysis: Don't crash if there is no constant operand.
This makes the code match the comments. Resolves a crash in loop idiom (PR14219).
llvm-svn: 167110
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/DependenceAnalysis.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index f97f0f2de60..c1321b63f28 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/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()); |