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 | b4a7fea7fde104a8c81fffb1cf7b8227af8fc845 (patch) | |
tree | 98c01a7abfaec4f7fd6d5f4c41e780501b918bb8 /lib/Analysis/ScalarEvolution.cpp | |
parent | cc1731c36b660b73ba03e3cc92414b5c932c586d (diff) |
For PR1336:
Fix a div-by-zero bug noticed by APInt. This fixes:
test/Transforms/IndVarsSimplify/exit_value_tests.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 54848e96a2..89067539c3 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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)); |