[pypy-svn] pypy default: Test and fix.

arigo commits-noreply at bitbucket.org
Mon Feb 21 16:13:26 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r42199:f185f9ad6796
Date: 2011-02-21 14:07 +0000
http://bitbucket.org/pypy/pypy/changeset/f185f9ad6796/

Log:	Test and fix.

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
@@ -176,12 +176,18 @@
     def test_casts(self):
         self.do_check('cast_int_to_longlong', EffectInfo.OS_LLONG_FROM_INT,
                       [lltype.Signed], lltype.SignedLongLong)
+        self.do_check('cast_uint_to_longlong', EffectInfo.OS_LLONG_FROM_UINT,
+                      [lltype.Unsigned], lltype.SignedLongLong)
         self.do_check('truncate_longlong_to_int', EffectInfo.OS_LLONG_TO_INT,
                       [lltype.SignedLongLong], lltype.Signed)
         self.do_check('cast_float_to_longlong', EffectInfo.OS_LLONG_FROM_FLOAT,
                       [lltype.Float], lltype.SignedLongLong)
         self.do_check('cast_longlong_to_float', EffectInfo.OS_LLONG_TO_FLOAT,
                       [lltype.SignedLongLong], lltype.Float)
+        for T1 in [lltype.SignedLongLong, lltype.UnsignedLongLong]:
+            for T2 in [lltype.Signed, lltype.Unsigned]:
+                self.do_check('cast_primitive', EffectInfo.OS_LLONG_TO_INT,
+                              [T1], T2)
 
     def test_constants(self):
         for TYPE in [lltype.SignedLongLong, lltype.UnsignedLongLong]:

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
@@ -834,8 +834,10 @@
                 op2 = self._handle_oopspec_call(op1, args,
                                                 EffectInfo.OS_LLONG_%s,
                                                 EffectInfo.EF_PURE)
+                if %r == "TO_INT":
+                    assert op2.result.concretetype == lltype.Signed
                 return op2
-        ''' % (_op, _oopspec.lower(), _oopspec)).compile()
+        ''' % (_op, _oopspec.lower(), _oopspec, _oopspec)).compile()
 
     def _normalize(self, oplist):
         if isinstance(oplist, SpaceOperation):
@@ -873,14 +875,24 @@
             args = op.args
             if fromll:
                 opname = 'truncate_longlong_to_int'
+                RESULT = lltype.Signed
             else:
                 from pypy.rpython.lltypesystem import rffi
                 if rffi.cast(op.args[0].concretetype, -1) < 0:
                     opname = 'cast_int_to_longlong'
                 else:
                     opname = 'cast_uint_to_longlong'
-            op1 = SpaceOperation(opname, args, op.result)
-            return self.rewrite_operation(op1)
+                RESULT = lltype.SignedLongLong
+            v = varoftype(RESULT)
+            op1 = SpaceOperation(opname, args, v)
+            op2 = self.rewrite_operation(op1)
+            #
+            # force a renaming to put the correct result in place, even though
+            # it might be slightly mistyped (e.g. Signed versus Unsigned)
+            assert op2.result is v
+            op2.result = op.result
+            #
+            return op2
 
     # ----------
     # Renames, from the _old opname to the _new one.


More information about the Pypy-commit mailing list