Author: Armin Rigo <[email protected]>
Branch: remove-raisingops
Changeset: r84744:6686cab4b2f2
Date: 2016-05-27 23:20 +0100
http://bitbucket.org/pypy/pypy/changeset/6686cab4b2f2/
Log: fix tests
diff --git a/pypy/module/pypyjit/test_pypy_c/test_shift.py
b/pypy/module/pypyjit/test_pypy_c/test_shift.py
--- a/pypy/module/pypyjit/test_pypy_c/test_shift.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_shift.py
@@ -78,6 +78,44 @@
i6 = int_xor(i5, i2)
""" % args)
+ def test_modulo_optimization(self):
+ def main(b):
+ res = 0
+ a = 0
+ while a < 300:
+ res1 = a%b # ID: mod
+ res2 = a%2 # ID: and
+ res3 = a%11 # ID: mul
+ res += res1 + res2 + res3
+ a += 1
+ return res
+ #
+ log = self.run(main, [3])
+ assert log.result == main(3)
+ loop, = log.loops_by_filename(self.filepath)
+ assert loop.match_by_id('mod', """
+ i56 = int_eq(i48, %d)
+ i57 = int_and(i56, i37)
+ guard_false(i57, descr=...)
+ i1 = call_i(_, i48, i3, descr=...)
+ """ % (-sys.maxint-1,))
+ assert loop.match_by_id('and', """
+ i1 = int_and(i2, 1)
+ """)
+ if sys.maxint > 2**32:
+ args = (63, -5030930201920786804, 3)
+ else:
+ args = (31, -1171354717, 3)
+ assert loop.match_by_id('mul', """
+ i2 = int_rshift(i1, %d)
+ i3 = int_xor(i1, i2)
+ i4 = uint_mul_high(i3, %d)
+ i5 = uint_rshift(i4, %d)
+ i6 = int_xor(i5, i2)
+ i7 = int_mul(i6, 11)
+ i8 = int_sub(i1, i7)
+ """ % args)
+
def test_division_to_rshift_allcases(self):
"""
This test only checks that we get the expected result, not that any
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py
b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -54,12 +54,25 @@
log = self.run(main, [1100], import_site=True)
assert log.result == main(1100)
loop, = log.loops_by_filename(self.filepath)
+ if sys.maxint > 2**32:
+ args = (63, -3689348814741910323, 3)
+ else:
+ args = (31, -858993459, 3)
assert loop.match("""
i11 = int_lt(i6, i7)
guard_true(i11, descr=...)
guard_not_invalidated(descr=...)
i13 = int_eq(i6, %d) # value provided below
- i19 = call_i(ConstClass(ll_int_mod__Signed_Signed), i6, 10,
descr=<Calli . ii EF=0 OS=14>)
+
+ # "mod 10" block:
+ i79 = int_rshift(i6, %d)
+ i80 = int_xor(i6, i79)
+ i82 = uint_mul_high(i80, %d)
+ i84 = uint_rshift(i82, %d)
+ i85 = int_xor(i84, i79)
+ i87 = int_mul(i85, 10)
+ i19 = int_sub(i6, i87)
+
i23 = strgetitem(p10, i19)
p25 = newstr(1)
strsetitem(p25, 0, i23)
@@ -74,7 +87,7 @@
guard_no_overflow(descr=...)
--TICK--
jump(..., descr=...)
- """ % (-sys.maxint-1,))
+ """ % ((-sys.maxint-1,)+args))
def test_str_mod(self):
def main(n):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit