diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-04-16 01:48:37 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-04-16 01:48:37 +0000 |
commit | 8be22e4e04743c444315bf94bc62e1a228272f61 (patch) | |
tree | a99c3e30a12e1d00cf5e2b83c2f45d76d77c5d53 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 59d3ca99b6e4c3073b776ef7f4f73fc912cfe118 (diff) | |
download | bcm5719-llvm-8be22e4e04743c444315bf94bc62e1a228272f61.tar.gz bcm5719-llvm-8be22e4e04743c444315bf94bc62e1a228272f61.zip |
For PR1336:
Fix a div-by-zero bug noticed by APInt. This fixes:
test/Transforms/IndVarsSimplify/exit_value_tests.llx
llvm-svn: 36099
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 54848e96a21..89067539c32 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -2125,7 +2125,12 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec) { // Compute the two solutions for the quadratic formula. // The divisions must be performed as signed divisions. APInt NegB(-B); - APInt TwoA(A << 1); + APInt TwoA( A << Two ); + if (TwoA == 0) { + const Type* Ty = LC->getValue()->getType(); + return std::make_pair(SCEVUnknown::get(UndefValue::get(Ty)), + SCEVUnknown::get(UndefValue::get(Ty))); + } ConstantInt *Solution1 = ConstantInt::get((NegB + SqrtVal).sdiv(TwoA)); ConstantInt *Solution2 = ConstantInt::get((NegB - SqrtVal).sdiv(TwoA)); |