[llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp
Reid Spencer
reid at x10sys.com
Sun Apr 15 18:48:58 PDT 2007
Changes in directory llvm/lib/Analysis:
ScalarEvolution.cpp updated: 1.110 -> 1.111
---
Log message:
For PR1336: http://llvm.org/PR1336 :
Fix a div-by-zero bug noticed by APInt. This fixes:
test/Transforms/IndVarsSimplify/exit_value_tests.llx
---
Diffs of the changes: (+6 -1)
ScalarEvolution.cpp | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletion(-)
Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.110 llvm/lib/Analysis/ScalarEvolution.cpp:1.111
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.110 Sun Apr 15 14:52:49 2007
+++ llvm/lib/Analysis/ScalarEvolution.cpp Sun Apr 15 20:48:37 2007
@@ -2125,7 +2125,12 @@
// 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));
More information about the llvm-commits
mailing list