[pypy-svn] r20849 - in pypy/dist/pypy/jit: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Dec 7 17:24:51 CET 2005
Author: cfbolz
Date: Wed Dec 7 17:24:50 2005
New Revision: 20849
Modified:
pypy/dist/pypy/jit/llabstractinterp.py
pypy/dist/pypy/jit/test/test_llabstractinterp.py
Log:
(cfbolz, arigo, pedronis)
A few more tests and operations.
Modified: pypy/dist/pypy/jit/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/llabstractinterp.py Wed Dec 7 17:24:50 2005
@@ -266,3 +266,12 @@
def op_int_add(self, op, a1, a2):
return self.residualize(op, [a1, a2], operator.add)
+
+ def op_int_sub(self, op, a1, a2):
+ return self.residualize(op, [a1, a2], operator.sub)
+
+ def op_int_gt(self, op, a1, a2):
+ return self.residualize(op, [a1, a2], operator.gt)
+
+ def op_same_as(self, op, a):
+ return a
Modified: pypy/dist/pypy/jit/test/test_llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_llabstractinterp.py (original)
+++ pypy/dist/pypy/jit/test/test_llabstractinterp.py Wed Dec 7 17:24:50 2005
@@ -94,3 +94,40 @@
return y
graph2, insns = abstrinterp(ll_function, [6, 42], [])
assert insns == {'int_is_true': 1, 'int_add': 2}
+
+def test_unrolling_loop():
+ def ll_function(x, y):
+ while x > 0:
+ y += x
+ x -= 1
+ return y
+ graph2, insns = abstrinterp(ll_function, [6, 42], [0])
+ assert insns == {'int_add': 6}
+
+def test_loop():
+ def ll_function(x, y):
+ while x > 0:
+ y += x
+ x -= 1
+ return y
+ graph2, insns = abstrinterp(ll_function, [6, 42], [])
+ assert insns == {'int_gt': 1, 'int_add': 1, 'int_sub': 1}
+
+def test_loop2():
+ def ll_function(x, y):
+ while x > 0:
+ y += x
+ x -= 1
+ return y
+ graph2, insns = abstrinterp(ll_function, [6, 42], [1])
+ assert insns == {'int_gt': 2, 'int_add': 2, 'int_sub': 2}
+
+def test_not_merging():
+ def ll_function(x, y, z):
+ if x:
+ a = y + z
+ else:
+ a = y - z
+ return a + x
+ graph2, insns = abstrinterp(ll_function, [3, 4, 5], [1, 2])
+ assert insns == {'int_is_true': 1, 'int_add': 2}
More information about the Pypy-commit
mailing list