[pypy-svn] pypy jit-int: Allow mod to be optimized too
hakanardo
commits-noreply at bitbucket.org
Tue Jan 11 08:11:03 CET 2011
Author: Hakan Ardo <hakan at debian.org>
Branch: jit-int
Changeset: r40570:e54f20efa94e
Date: 2011-01-11 08:09 +0100
http://bitbucket.org/pypy/pypy/changeset/e54f20efa94e/
Log: Allow mod to be optimized too
diff --git a/pypy/rpython/rint.py b/pypy/rpython/rint.py
--- a/pypy/rpython/rint.py
+++ b/pypy/rpython/rint.py
@@ -238,7 +238,7 @@
# return r + y*(((x^y)<0)&(r!=0));
v_xor = hop.genop(prefix + 'xor', vlist,
resulttype=repr)
- v_xor_le = hop.genop(prefix + 'le', [v_xor, c_zero],
+ v_xor_le = hop.genop(prefix + 'lt', [v_xor, c_zero],
resulttype=Bool)
v_xor_le = hop.llops.convertvar(v_xor_le, bool_repr, repr)
v_mod_ne = hop.genop(prefix + 'ne', [v_res, c_zero],
diff --git a/pypy/module/pypyjit/test/test_pypy_c.py b/pypy/module/pypyjit/test/test_pypy_c.py
--- a/pypy/module/pypyjit/test/test_pypy_c.py
+++ b/pypy/module/pypyjit/test/test_pypy_c.py
@@ -1436,6 +1436,41 @@
([a3, b3], 2000 * res3),
count_debug_merge_point=False)
+ def test_mod(self):
+ py.test.skip('Results are correct, but traces 1902 times (on trunk too).')
+ avalues = ('a', 'b', 7, -42, 8)
+ bvalues = ['b'] + range(-10, 0) + range(1,10)
+ code = ''
+ a1, b1, res1 = 10, 20, 0
+ a2, b2, res2 = 10, -20, 0
+ a3, b3, res3 = -10, -20, 0
+ def dd(a, b, aval, bval):
+ m = {'a': aval, 'b': bval}
+ if not isinstance(a, int):
+ a=m[a]
+ if not isinstance(b, int):
+ b=m[b]
+ return a % b
+ for a in avalues:
+ for b in bvalues:
+ code += ' sa += %s %% %s\n' % (a, b)
+ res1 += dd(a, b, a1, b1)
+ res2 += dd(a, b, a2, b2)
+ res3 += dd(a, b, a3, b3)
+ self.run_source('''
+ def main(a, b):
+ i = sa = 0
+ while i < 2000:
+ if a > 0: pass
+ if 1 < b < 2: pass
+%s
+ i += 1
+ return sa
+ ''' % code, 0, ([a1, b1], 2000 * res1),
+ ([a2, b2], 2000 * res2),
+ ([a3, b3], 2000 * res3),
+ count_debug_merge_point=False)
+
class AppTestJIT(PyPyCJITTests):
def setup_class(cls):
More information about the Pypy-commit
mailing list