[pypy-svn] pypy jit-longlong: Remove OS_LLONG_IS_TRUE, and generate it as a LLONG_NE(x, 0).

arigo commits-noreply at bitbucket.org
Sun Jan 9 15:52:00 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40525:4a2f29fbb11d
Date: 2011-01-09 15:51 +0100
http://bitbucket.org/pypy/pypy/changeset/4a2f29fbb11d/

Log:	Remove OS_LLONG_IS_TRUE, and generate it as a LLONG_NE(x, 0).

diff --git a/pypy/jit/codewriter/test/test_longlong.py b/pypy/jit/codewriter/test/test_longlong.py
--- a/pypy/jit/codewriter/test/test_longlong.py
+++ b/pypy/jit/codewriter/test/test_longlong.py
@@ -58,10 +58,29 @@
         assert op1.result == v_result
 
     def test_is_true(self):
-        self.do_check('llong_is_true', EffectInfo.OS_LLONG_IS_TRUE,
-                      [lltype.SignedLongLong], lltype.Bool)
-        self.do_check('ullong_is_true', EffectInfo.OS_LLONG_IS_TRUE,
-                      [lltype.SignedLongLong], lltype.Bool)
+        for opname, T in [('llong_is_true', lltype.SignedLongLong),
+                          ('ullong_is_true', lltype.UnsignedLongLong)]:
+            v = varoftype(T)
+            v_result = varoftype(lltype.Bool)
+            op = SpaceOperation(opname, [v], v_result)
+            tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
+            oplist = tr.rewrite_operation(op)
+            assert len(oplist) == 2
+            assert oplist[0].opname == 'residual_call_irf_f'
+            assert oplist[0].args[0].value == 'llong_from_int'
+            assert oplist[0].args[1] == 'calldescr-84'
+            assert list(oplist[0].args[2]) == [const(0)]
+            assert list(oplist[0].args[3]) == []
+            assert list(oplist[0].args[4]) == []
+            v_x = oplist[0].result
+            assert isinstance(v_x, Variable)
+            assert oplist[1].opname == 'residual_call_irf_i'
+            assert oplist[1].args[0].value == 'llong_ne'
+            assert oplist[1].args[1] == 'calldescr-76'
+            assert list(oplist[1].args[2]) == []
+            assert list(oplist[1].args[3]) == []
+            assert list(oplist[1].args[4]) == [v, v_x]
+            assert oplist[1].result == v_result
 
     def test_llong_neg(self):
         T = lltype.SignedLongLong

diff --git a/pypy/jit/codewriter/support.py b/pypy/jit/codewriter/support.py
--- a/pypy/jit/codewriter/support.py
+++ b/pypy/jit/codewriter/support.py
@@ -229,9 +229,6 @@
 def u_to_longlong(x):
     return rffi.cast(lltype.SignedLongLong, x)
 
-def _ll_1_llong_is_true(xll):
-    return bool(xll)
-
 def _ll_1_llong_invert(xll):
     y = ~r_ulonglong(xll)
     return u_to_longlong(y)

diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -47,7 +47,6 @@
     OS_LIBFFI_PUSH_ARG          = 61
     OS_LIBFFI_CALL              = 62
     #
-    OS_LLONG_IS_TRUE            = 67
     OS_LLONG_INVERT             = 69
     OS_LLONG_ADD                = 70
     OS_LLONG_SUB                = 71

diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -825,9 +825,7 @@
                 args[i] = v_x
         return args
 
-    for _op, _oopspec in [('llong_is_true', 'IS_TRUE'),
-                          ('ullong_is_true','IS_TRUE'),
-                          ('llong_invert',  'INVERT'),
+    for _op, _oopspec in [('llong_invert',  'INVERT'),
                           ('ullong_invert', 'INVERT'),
                           ('llong_lt',      'LT'),
                           ('llong_le',      'LE'),
@@ -880,6 +878,13 @@
         op1 = SpaceOperation('llong_sub', args, op.result)
         return self.rewrite_operation(op1)
 
+    def rewrite_op_llong_is_true(self, op):
+        args = [op.args[0], Constant(0, lltype.SignedLongLong)]
+        op1 = SpaceOperation('llong_ne', args, op.result)
+        return self.rewrite_operation(op1)
+
+    rewrite_op_ullong_is_true = rewrite_op_llong_is_true
+
     def rewrite_op_cast_primitive(self, op):
         fromll = self._is_longlong(op.args[0].concretetype)
         toll   = self._is_longlong(op.result.concretetype)


More information about the Pypy-commit mailing list