[pypy-commit] pypy default: Fix the failing test of 4b58008df717
arigo
pypy.commits at gmail.com
Sun May 8 12:36:41 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r84289:d07e57c5d7f3
Date: 2016-05-08 18:36 +0200
http://bitbucket.org/pypy/pypy/changeset/d07e57c5d7f3/
Log: Fix the failing test of 4b58008df717
diff --git a/rpython/jit/metainterp/optimizeopt/intutils.py b/rpython/jit/metainterp/optimizeopt/intutils.py
--- a/rpython/jit/metainterp/optimizeopt/intutils.py
+++ b/rpython/jit/metainterp/optimizeopt/intutils.py
@@ -1,5 +1,8 @@
+import sys
from rpython.rlib.rarithmetic import ovfcheck, LONG_BIT, maxint, is_valid_int
from rpython.rlib.objectmodel import we_are_translated
+from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem.lloperation import llop
from rpython.jit.metainterp.resoperation import rop, ResOperation
from rpython.jit.metainterp.optimizeopt.info import AbstractInfo, INFO_NONNULL,\
INFO_UNKNOWN, INFO_NULL
@@ -174,15 +177,13 @@
def div_bound(self, other):
if self.has_upper and self.has_lower and \
other.has_upper and other.has_lower and \
- not other.contains(0):
- try:
- vals = (ovfcheck(self.upper / other.upper),
- ovfcheck(self.upper / other.lower),
- ovfcheck(self.lower / other.upper),
- ovfcheck(self.lower / other.lower))
- return IntBound(min4(vals), max4(vals))
- except OverflowError:
- return IntUnbounded()
+ not other.contains(0) and self.lower > (-sys.maxint-1):
+ vals = (
+ llop.int_floordiv(lltype.Signed, self.upper, other.upper),
+ llop.int_floordiv(lltype.Signed, self.upper, other.lower),
+ llop.int_floordiv(lltype.Signed, self.lower, other.upper),
+ llop.int_floordiv(lltype.Signed, self.lower, other.lower))
+ return IntBound(min4(vals), max4(vals))
else:
return IntUnbounded()
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_intbound.py b/rpython/jit/metainterp/optimizeopt/test/test_intbound.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_intbound.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_intbound.py
@@ -240,6 +240,8 @@
def test_div_bound():
+ from rpython.rtyper.lltypesystem import lltype
+ from rpython.rtyper.lltypesystem.lloperation import llop
for _, _, b1 in some_bounds():
for _, _, b2 in some_bounds():
b3 = b1.div_bound(b2)
@@ -247,7 +249,8 @@
for n2 in nbr:
if b1.contains(n1) and b2.contains(n2):
if n2 != 0:
- assert b3.contains(n1 / n2)
+ assert b3.contains(
+ llop.int_floordiv(lltype.Signed, n1, n2))
a=bound(2, 4).div_bound(bound(1, 2))
assert not a.contains(0)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -5546,7 +5546,7 @@
expected = """
[i4, i5]
escape_n(-1)
- jump(i4, i5)
+ jump(i4, -1)
"""
self.optimize_loop(ops, expected)
More information about the pypy-commit
mailing list