[pypy-commit] pypy remove-raisingops: tweaks, reducing diff to default
arigo
pypy.commits at gmail.com
Fri May 27 05:19:46 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: remove-raisingops
Changeset: r84725:3da1c3d6dbae
Date: 2016-05-27 11:19 +0200
http://bitbucket.org/pypy/pypy/changeset/3da1c3d6dbae/
Log: tweaks, reducing diff to default
diff --git a/rpython/jit/backend/llsupport/test/test_regalloc_integration.py b/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
--- a/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
+++ b/rpython/jit/backend/llsupport/test/test_regalloc_integration.py
@@ -496,23 +496,6 @@
self.interpret(ops, [s, ord('a')])
assert s[1] == 'a'
- def test_division_optimized(self):
- py.test.skip("XXX re-enable")
- ops = '''
- [i7, i6]
- label(i7, i6, descr=targettoken)
- i18 = int_floordiv(i7, i6)
- i19 = int_xor(i7, i6)
- i21 = int_lt(i19, 0)
- i22 = int_mod(i7, i6)
- i23 = int_is_true(i22)
- i24 = int_eq(i6, 4)
- guard_false(i24) [i18]
- jump(i18, i6, descr=targettoken)
- '''
- self.interpret(ops, [10, 4])
- assert self.getint(0) == 2
- # FIXME: Verify that i19 - i23 are removed
class TestRegallocFloats(BaseTestRegalloc):
def setup_class(cls):
diff --git a/rpython/jit/codewriter/support.py b/rpython/jit/codewriter/support.py
--- a/rpython/jit/codewriter/support.py
+++ b/rpython/jit/codewriter/support.py
@@ -413,21 +413,6 @@
else:
return xll
-def _ll_2_llong_floordiv(xll, yll):
- return llop.llong_floordiv(lltype.SignedLongLong, xll, yll)
-
-def _ll_2_llong_mod(xll, yll):
- return llop.llong_mod(lltype.SignedLongLong, xll, yll)
-
-def _ll_2_ullong_floordiv(xll, yll):
- return llop.ullong_floordiv(lltype.UnsignedLongLong, xll, yll)
-
-def _ll_2_ullong_mod(xll, yll):
- return llop.ullong_mod(lltype.UnsignedLongLong, xll, yll)
-
-def _ll_2_uint_mod(xll, yll):
- return llop.uint_mod(lltype.Unsigned, xll, yll)
-
# in the following calls to builtins, the JIT is allowed to look inside:
inline_calls_to = [
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -710,7 +710,7 @@
from rpython.jit.metainterp.history import DONT_CHANGE
op = self.replace_op_with(op, rop.INT_RSHIFT,
args=[arg1, ConstInt(highest_bit(val))],
- descr=DONT_CHANGE) # <- xxx rename?
+ descr=DONT_CHANGE) # <- xxx rename? means "kill"
self.emit_operation(op)
return True
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vecopt.py
@@ -725,7 +725,7 @@
ops = """
[p0,i0]
i1 = int_add(i0,4)
- i2 = int_sub(i1,3) # XXX used to be "divide by 4", not sure about it
+ i2 = int_sub(i1,3) # XXX used to be "divide by 2", not sure about it
i3 = raw_load_i(p0,i2,descr=chararraydescr)
i4 = int_add(i0,2)
i5 = int_mul(i4,2)
diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -936,11 +936,11 @@
myjitdriver.can_enter_jit(x=x, y=y, n=n)
myjitdriver.jit_merge_point(x=x, y=y, n=n)
n -= ovfcheck(x % y)
+ x += 1
return n
res = self.meta_interp(f, [20, 1, 2])
assert res == 0
- py.test.skip("XXX re-enable")
- self.check_resops(call_i=0, call_r=0)
+ self.check_resops(call_i=2, int_eq=3, int_and=2)
def test_abs(self):
myjitdriver = JitDriver(greens = [], reds = ['i', 't'])
diff --git a/rpython/jit/metainterp/test/test_executor.py b/rpython/jit/metainterp/test/test_executor.py
--- a/rpython/jit/metainterp/test/test_executor.py
+++ b/rpython/jit/metainterp/test/test_executor.py
@@ -142,18 +142,6 @@
(133, 133, 0)]),
(rop.INT_MUL, [(-6, -3, 18),
(15, 15, 225)]),
- ## (rop.INT_FLOORDIV, [(110, 3, 36),
- ## (-110, 3, -36),
- ## (110, -3, -36),
- ## (-110, -3, 36),
- ## (-110, -1, 110),
- ## (minint, 1, minint),
- ## (-87, -87, 1)]),
- ## (rop.INT_MOD, [(11, 3, 2),
- ## (-11, 3, -2),
- ## (11, -3, 2),
- ## (-11, -3, -2),
- ## (-87, -87, 0)]),
(rop.INT_AND, [(0xFF00, 0x0FF0, 0x0F00),
(-111, -111, -111)]),
(rop.INT_OR, [(0xFF00, 0x0FF0, 0xFFF0),
@@ -170,15 +158,6 @@
(rop.UINT_RSHIFT, [(-1, 4, intmask(r_uint(-1) >> r_uint(4))),
( 1, 4, intmask(r_uint(1) >> r_uint(4))),
( 3, 3, 0)]),
- ## (rop.UINT_FLOORDIV, [(4, 3, intmask(r_uint(4) / r_uint(3))),
- ## (1, -1, intmask(r_uint(1) / r_uint(-1))),
- ## (110, 3, 36),
- ## (-110, 3, intmask(r_uint(-110) / r_uint(3))),
- ## (110, -3, intmask(r_uint(110) / r_uint(-3))),
- ## (-110, -3, intmask(r_uint(-110) / r_uint(-3))),
- ## (-110, -1, intmask(r_uint(-110) / r_uint(-1))),
- ## (minint, 1, intmask(r_uint(minint) / r_uint(1))),
- ## (-87, -87, intmask(r_uint(-87) / r_uint(-87)))])
]:
for x, y, z in testcases:
yield opnum, [x, y], z
diff --git a/rpython/rlib/rerased.py b/rpython/rlib/rerased.py
--- a/rpython/rlib/rerased.py
+++ b/rpython/rlib/rerased.py
@@ -20,7 +20,7 @@
from rpython.rtyper.llannotation import lltype_to_annotation
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.rtyper.lltypesystem.lloperation import llop
-from rpython.rlib.rarithmetic import is_valid_int, r_uint, intmask
+from rpython.rlib.rarithmetic import is_valid_int
from rpython.rlib.debug import ll_assert
@@ -212,12 +212,12 @@
def _rtype_erase_int(hop):
[v_value] = hop.inputargs(lltype.Signed)
+ c_one = hop.inputconst(lltype.Signed, 1)
hop.exception_is_here()
- v_instance = hop.gendirectcall(_ll_erase_int, v_value)
+ v2 = hop.genop('int_add_ovf', [v_value, v_value],
+ resulttype = lltype.Signed)
+ v2p1 = hop.genop('int_add', [v2, c_one],
+ resulttype = lltype.Signed)
+ v_instance = hop.genop('cast_int_to_ptr', [v2p1],
+ resulttype=llmemory.GCREF)
return v_instance
-
-def _ll_erase_int(x):
- r = intmask(r_uint(x) << 1)
- if r^x < 0:
- raise OverflowError("integer addition")
- return lltype.cast_int_to_ptr(llmemory.GCREF, r + 1)
diff --git a/rpython/rtyper/lltypesystem/rtagged.py b/rpython/rtyper/lltypesystem/rtagged.py
--- a/rpython/rtyper/lltypesystem/rtagged.py
+++ b/rpython/rtyper/lltypesystem/rtagged.py
@@ -3,7 +3,6 @@
InstanceRepr, CLASSTYPE, ll_inst_type, MissingRTypeAttribute,
ll_issubclass_const, getclassrepr, getinstancerepr, get_type_repr)
from rpython.rtyper.rmodel import TyperError, inputconst
-from rpython.rlib.rarithmetic import r_uint, intmask
class TaggedInstanceRepr(InstanceRepr):
@@ -41,8 +40,12 @@
raise TyperError("must instantiate %r with a simple class call" % (
self.classdef,))
v_value = hop.inputarg(lltype.Signed, arg=1)
+ c_one = hop.inputconst(lltype.Signed, 1)
hop.exception_is_here()
- v2p1 = hop.gendirectcall(ll_times_two_plus_one, v_value)
+ v2 = hop.genop('int_add_ovf', [v_value, v_value],
+ resulttype = lltype.Signed)
+ v2p1 = hop.genop('int_add', [v2, c_one],
+ resulttype = lltype.Signed)
v_instance = hop.genop('cast_int_to_ptr', [v2p1],
resulttype = self.lowleveltype)
return v_instance, False # don't call __init__
@@ -137,11 +140,6 @@
return hop.gendirectcall(ll_unboxed_isinstance_const, v_obj,
minid, maxid, c_answer_if_unboxed)
-def ll_times_two_plus_one(x):
- r = intmask(r_uint(x) << 1)
- if r^x < 0:
- raise OverflowError("integer addition")
- return r + 1
def ll_int_to_unboxed(PTRTYPE, value):
return lltype.cast_int_to_ptr(PTRTYPE, value*2+1)
diff --git a/rpython/rtyper/lltypesystem/test/test_lloperation.py b/rpython/rtyper/lltypesystem/test/test_lloperation.py
--- a/rpython/rtyper/lltypesystem/test/test_lloperation.py
+++ b/rpython/rtyper/lltypesystem/test/test_lloperation.py
@@ -53,7 +53,7 @@
from rpython.flowspace.model import Variable, Constant
assert llop.bool_not.is_pure([Variable()])
assert llop.debug_assert.is_pure([Variable()])
- assert not llop.setarrayitem.is_pure([Variable(), Variable(), Variable()])
+ assert not llop.int_add_ovf.is_pure([Variable(), Variable()])
#
S1 = lltype.GcStruct('S', ('x', lltype.Signed), ('y', lltype.Signed))
v_s1 = Variable()
diff --git a/rpython/translator/c/src/commondefs.h b/rpython/translator/c/src/commondefs.h
--- a/rpython/translator/c/src/commondefs.h
+++ b/rpython/translator/c/src/commondefs.h
@@ -67,6 +67,7 @@
# define SIZEOF_INT 4
# define SIZEOF_LONG 4
+# define SIZEOF_SIGNED 4
# define SIZEOF_LONG_LONG 8
/******************** 64-bit support ********************/
@@ -82,6 +83,7 @@
# define SIZEOF_INT 4
# define SIZEOF_LONG 8
+# define SIZEOF_SIGNED 8
# define SIZEOF_LONG_LONG 8
/******************** Win-64 support ********************/
@@ -95,6 +97,7 @@
# define SIZEOF_INT 4
# define SIZEOF_LONG 4
+# define SIZEOF_SIGNED 8
# define SIZEOF_LONG_LONG 8
# endif
diff --git a/rpython/translator/c/src/int.h b/rpython/translator/c/src/int.h
--- a/rpython/translator/c/src/int.h
+++ b/rpython/translator/c/src/int.h
@@ -73,16 +73,16 @@
r = (Signed)((Unsigned)x - y); \
if ((r^x) < 0 && (r^~y) < 0) FAIL_OVF("integer subtraction")
-#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
+#if SIZEOF_SIGNED * 2 <= SIZEOF_LONG_LONG
#define OP_INT_MUL_OVF(x,y,r) \
{ \
long long _lr = (long long)x * y; \
- r = (long)_lr; \
+ r = (Signed)_lr; \
if (_lr != (long long)r) FAIL_OVF("integer multiplication"); \
}
#else
#define OP_INT_MUL_OVF(x,y,r) \
- r = op_llong_mul_ovf(x, y) /* long == long long */
+ r = op_llong_mul_ovf(x, y) /* Signed == long long */
#endif
#else /* HAVE_BUILTIN_OVERFLOW */
More information about the pypy-commit
mailing list