[pypy-svn] pypy jit-longlong: LLONG_NE. Phew.

arigo commits-noreply at bitbucket.org
Sun Jan 9 22:57:09 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: jit-longlong
Changeset: r40544:99536ded6eeb
Date: 2011-01-09 22:56 +0100
http://bitbucket.org/pypy/pypy/changeset/99536ded6eeb/

Log:	LLONG_NE. Phew.

diff --git a/pypy/jit/backend/x86/rx86.py b/pypy/jit/backend/x86/rx86.py
--- a/pypy/jit/backend/x86/rx86.py
+++ b/pypy/jit/backend/x86/rx86.py
@@ -448,6 +448,7 @@
     OR_ri,  OR_rr,  OR_rb,  _, _, OR_rm,  OR_rj  = common_modes(1)
     AND_ri, AND_rr, AND_rb, _, _, AND_rm, AND_rj = common_modes(4)
     SUB_ri, SUB_rr, SUB_rb, _, _, SUB_rm, SUB_rj = common_modes(5)
+    SBB_ri, SBB_rr, SBB_rb, _, _, SBB_rm, SBB_rj = common_modes(3)
     XOR_ri, XOR_rr, XOR_rb, _, _, XOR_rm, XOR_rj = common_modes(6)
     CMP_ri, CMP_rr, CMP_rb, CMP_bi, CMP_br, CMP_rm, CMP_rj = common_modes(7)
 
@@ -463,6 +464,8 @@
 
     CMP32_mi = insn(rex_nw, '\x81', orbyte(7<<3), mem_reg_plus_const(1), immediate(2))
 
+    CMP8_ri = insn(rex_nw, '\x80', byte_register(1), '\xF8', immediate(2, 'b'))
+
     AND8_rr = insn(rex_w, '\x20', byte_register(1), byte_register(2,8), '\xC0')
 
     OR8_rr = insn(rex_w, '\x08', byte_register(1), byte_register(2,8), '\xC0')

diff --git a/pypy/jit/backend/x86/assembler.py b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -1149,18 +1149,30 @@
             self.mc.PUNPCKLDQ_xx(resloc.value, loc3.value)
 
     def genop_llong_eq(self, op, arglocs, resloc):
-        loc1, loc2, locxtmp, loctmp = arglocs
+        loc1, loc2, locxtmp = arglocs
         self.mc.MOVSD_xx(locxtmp.value, loc1.value)
         self.mc.PCMPEQD_xx(locxtmp.value, loc2.value)
-        self.mc.PMOVMSKB_rx(loctmp.value, locxtmp.value)
+        self.mc.PMOVMSKB_rx(resloc.value, locxtmp.value)
         # Now the lower 8 bits of resloc contain 0x00, 0x0F, 0xF0 or 0xFF
         # depending on the result of the comparison of each of the two
         # double-words of loc1 and loc2.  The higher 8 bits contain random
         # results.  We want to map 0xFF to 1, and 0x00, 0x0F and 0xF0 to 0.
-        self.mc.MOV_rr(resloc.value, loctmp.value)
-        self.mc.SHR_ri(loctmp.value, 4)
-        self.mc.AND_ri(resloc.value, 1)
-        self.mc.AND_rr(resloc.value, loctmp.value)
+        self.mc.CMP8_ri(resloc.value | rx86.BYTE_REG_FLAG, -1)
+        self.mc.SBB_rr(resloc.value, resloc.value)
+        self.mc.ADD_ri(resloc.value, 1)
+
+    def genop_llong_ne(self, op, arglocs, resloc):
+        loc1, loc2, locxtmp = arglocs
+        self.mc.MOVSD_xx(locxtmp.value, loc1.value)
+        self.mc.PCMPEQD_xx(locxtmp.value, loc2.value)
+        self.mc.PMOVMSKB_rx(resloc.value, locxtmp.value)
+        # Now the lower 8 bits of resloc contain 0x00, 0x0F, 0xF0 or 0xFF
+        # depending on the result of the comparison of each of the two
+        # double-words of loc1 and loc2.  The higher 8 bits contain random
+        # results.  We want to map 0xFF to 0, and 0x00, 0x0F and 0xF0 to 1.
+        self.mc.CMP8_ri(resloc.value | rx86.BYTE_REG_FLAG, -1)
+        self.mc.SBB_rr(resloc.value, resloc.value)
+        self.mc.NEG_r(resloc.value)
 
     def genop_new_with_vtable(self, op, arglocs, result_loc):
         assert result_loc is eax

diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -649,11 +649,8 @@
         tmpxvar = TempBox()
         loc3 = self.xrm.force_allocate_reg(tmpxvar, args)
         self.xrm.possibly_free_var(tmpxvar)
-        tmpvar = TempBox()
-        loc4 = self.rm.force_allocate_reg(tmpvar)
-        loc0 = self.rm.force_allocate_reg(op.result, [tmpvar])
-        self.rm.possibly_free_var(tmpvar)
-        self.PerformLLong(op, [loc1, loc2, loc3, loc4], loc0)
+        loc0 = self.rm.force_allocate_reg(op.result, need_lower_byte=True)
+        self.PerformLLong(op, [loc1, loc2, loc3], loc0)
         self.xrm.possibly_free_vars(args)
 
     def _consider_llong_to_int(self, op):
@@ -769,7 +766,8 @@
                     return self._consider_llong_from_int(op)
                 if oopspecindex == EffectInfo.OS_LLONG_FROM_TWO_INTS:
                     return self._consider_llong_from_two_ints(op)
-                if oopspecindex == EffectInfo.OS_LLONG_EQ:
+                if (oopspecindex == EffectInfo.OS_LLONG_EQ or
+                    oopspecindex == EffectInfo.OS_LLONG_NE):
                     return self._consider_llong_cmp_xx(op)
         #
         self._consider_call(op)


More information about the Pypy-commit mailing list