[pypy-svn] r75308 - in pypy/branch/int-between/pypy/jit/metainterp: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Jun 12 10:13:50 CEST 2010
Author: arigo
Date: Sat Jun 12 10:13:48 2010
New Revision: 75308
Modified:
pypy/branch/int-between/pypy/jit/metainterp/pyjitpl.py
pypy/branch/int-between/pypy/jit/metainterp/test/test_basic.py
Log:
Implement the common case of int_betwen(a, b, a+1)
in pyjitpl too.
Modified: pypy/branch/int-between/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/int-between/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/int-between/pypy/jit/metainterp/pyjitpl.py Sat Jun 12 10:13:48 2010
@@ -317,9 +317,13 @@
@arguments("box", "box", "box")
def opimpl_int_between(self, b1, b2, b3):
- b4 = self.execute(rop.INT_SUB, b2, b1)
b5 = self.execute(rop.INT_SUB, b3, b1)
- return self.execute(rop.UINT_LT, b4, b5)
+ if isinstance(b5, ConstInt) and b5.getint() == 1:
+ # the common case of int_between(a, b, a+1) turns into just INT_EQ
+ return self.execute(rop.INT_EQ, b2, b1)
+ else:
+ b4 = self.execute(rop.INT_SUB, b2, b1)
+ return self.execute(rop.UINT_LT, b4, b5)
@arguments("box", "descr", "orgpc")
def opimpl_switch(self, valuebox, switchdict, orgpc):
Modified: pypy/branch/int-between/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/int-between/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/int-between/pypy/jit/metainterp/test/test_basic.py Sat Jun 12 10:13:48 2010
@@ -602,6 +602,8 @@
check(2, 'n', 6, True, int_sub=1, uint_lt=1)
check(2, 'm', 6, False, int_sub=1, uint_lt=1)
check(2, 'p', 6, False, int_sub=1, uint_lt=1)
+ check(5, 'n', 6, True, int_eq=1) # 6 == 5+1
+ check(5, 'm', 6, False, int_eq=1) # 6 == 5+1
#
check(2, 6, 'm', False, int_sub=1, uint_lt=1)
check(2, 6, 'p', True, int_sub=1, uint_lt=1)
More information about the Pypy-commit
mailing list