[pypy-svn] r64022 - in pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Mon Apr 13 07:59:01 CEST 2009


Author: fijal
Date: Mon Apr 13 07:59:01 2009
New Revision: 64022

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
Log:
a test for all possible cases + correct fix


Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/assembler.py	Mon Apr 13 07:59:01 2009
@@ -368,10 +368,10 @@
             if isinstance(op.args[0], Const):
                 self.mc.CMP(arglocs[1], arglocs[0])
                 if guard_op.opnum == rop.GUARD_FALSE:
-                    name = 'J' + false_rev_cond
+                    name = 'J' + rev_cond
                     self.implement_guard(addr, guard_op, getattr(self.mc, name))
                 else:
-                    name = 'J' + rev_cond
+                    name = 'J' + false_rev_cond
                     self.implement_guard(addr, guard_op, getattr(self.mc, name))
             else:
                 self.mc.CMP(arglocs[0], arglocs[1])
@@ -431,8 +431,8 @@
 
     genop_guard_int_lt = _cmpop_guard("L", "G", "GE", "LE")
     genop_guard_int_le = _cmpop_guard("LE", "GE", "G", "L")
-    genop_guard_int_eq = _cmpop_guard("E", "NE", "NE", "E")
-    genop_guard_int_ne = _cmpop_guard("NE", "E", "E", "NE")
+    genop_guard_int_eq = _cmpop_guard("E", "E", "NE", "NE")
+    genop_guard_int_ne = _cmpop_guard("NE", "NE", "E", "E")
     genop_guard_int_gt = _cmpop_guard("G", "L", "LE", "GE")
     genop_guard_int_ge = _cmpop_guard("GE", "LE", "L", "G")
 

Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/x86/test/test_runner.py	Mon Apr 13 07:59:01 2009
@@ -455,21 +455,44 @@
         op = self.cpu.execute_operations(loop, [p])
         assert op.args[0].value == 0
 
-    def test_int_eq_guard_fals(self):
-        v = BoxInt(1)
-        res = BoxInt()
-        ops = [
-            ResOperation(rop.INT_EQ, [ConstInt(0), v], res),
-            ResOperation(rop.GUARD_FALSE, [res], None),
-            ResOperation(rop.FAIL, [ConstInt(0)], None),
-            ]
-        ops[1].suboperations = [ResOperation(rop.FAIL, [ConstInt(1)], None)]
-        loop = TreeLoop('name')
-        loop.operations = ops
-        loop.inputargs = [v]
-        self.cpu.compile_operations(loop)
-        op = self.cpu.execute_operations(loop, [v])
-        assert op.args[0].value == 0
+    def test_stuff_followed_by_guard(self):
+        boxes = [(BoxInt(1), BoxInt(0)),
+                 (BoxInt(0), BoxInt(1)),
+                 (BoxInt(1), BoxInt(1)),
+                 (BoxInt(-1), BoxInt(1)),
+                 (BoxInt(1), BoxInt(-1)),
+                 (ConstInt(1), BoxInt(0)),
+                 (ConstInt(0), BoxInt(1)),
+                 (ConstInt(1), BoxInt(1)),
+                 (ConstInt(-1), BoxInt(1)),
+                 (ConstInt(1), BoxInt(-1)),
+                 (BoxInt(1), ConstInt(0)),
+                 (BoxInt(0), ConstInt(1)),
+                 (BoxInt(1), ConstInt(1)),
+                 (BoxInt(-1), ConstInt(1)),
+                 (BoxInt(1), ConstInt(-1))]
+        guards = [rop.GUARD_FALSE, rop.GUARD_TRUE]
+        all = [rop.INT_EQ, rop.INT_NE, rop.INT_LE, rop.INT_LT, rop.INT_GT,
+               rop.INT_GE, rop.UINT_GT, rop.UINT_LT, rop.UINT_LE, rop.UINT_GE]
+        for a, b in boxes:
+            for guard in guards:
+                for op in all:
+                    res = BoxInt()
+                    ops = [
+                        ResOperation(op, [a, b], res),
+                        ResOperation(guard, [res], None),
+                        ResOperation(rop.FAIL, [ConstInt(0)], None),
+                        ]
+                    ops[1].suboperations = [ResOperation(rop.FAIL, [ConstInt(1)], None)]
+                    loop = TreeLoop('name')
+                    loop.operations = ops
+                    loop.inputargs = [i for i in (a, b) if isinstance(i, Box)]
+                    self.cpu.compile_operations(loop)
+                    r = self.cpu.execute_operations(loop, loop.inputargs)
+                    if guard == rop.GUARD_FALSE:
+                        assert r.args[0].value == execute(self.cpu, op, (a, b)).value
+                    else:
+                        assert r.args[0].value != execute(self.cpu, op, (a, b)).value
 
     def test_overflow_mc(self):
         from pypy.jit.backend.x86.assembler import MachineCodeBlockWrapper



More information about the Pypy-commit mailing list