[pypy-svn] r37508 - in pypy/dist/pypy/jit/codegen: ppc test

mwh at codespeak.net mwh at codespeak.net
Mon Jan 29 10:55:40 CET 2007


Author: mwh
Date: Mon Jan 29 10:55:37 2007
New Revision: 37508

Modified:
   pypy/dist/pypy/jit/codegen/ppc/rgenop.py
   pypy/dist/pypy/jit/codegen/test/rgenop_tests.py
Log:
FINALLY i worked out why enter_next_block needs to weed out duplicate vars.
with test.


Modified: pypy/dist/pypy/jit/codegen/ppc/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/ppc/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/ppc/rgenop.py	Mon Jan 29 10:55:37 2007
@@ -334,10 +334,14 @@
 ##     def genop_debug_pdb(self):    # may take an args_gv later
 
     def enter_next_block(self, kinds, args_gv):
+        seen = {}
         for i in range(len(args_gv)):
             gv = args_gv[i]
             if isinstance(gv, Var):
-                pass
+                if gv in seen:
+                    new_gv = self._arg_op(gv, _PPC.mr)
+                    args_gv[i] = new_gv
+                seen[gv] = True
             else:
                 new_gv = Var()
                 gv.load(self.insns, new_gv)

Modified: pypy/dist/pypy/jit/codegen/test/rgenop_tests.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/test/rgenop_tests.py	(original)
+++ pypy/dist/pypy/jit/codegen/test/rgenop_tests.py	Mon Jan 29 10:55:37 2007
@@ -1279,3 +1279,41 @@
         assert res == -100
         res = fn(606)
         assert res == 4242
+
+    def test_unaliasing_variables_direct(self):
+        # def f(x, y):
+        #     if x:
+        #        a = b = y
+        #     else:
+        #        a = 2
+        #        b = 1
+        #     return a+b
+
+        rgenop = self.RGenOp()
+
+        signed_kind = rgenop.kindToken(lltype.Signed)
+        sigtoken = rgenop.sigToken(FUNC2)
+        builder, gv_callable, [gv_x, gv_y] = rgenop.newgraph(sigtoken, "f")
+        builder.start_writing()
+
+        false_builder = builder.jump_if_false(gv_x, [])
+
+        args_gv = [gv_y, gv_y]
+        label = builder.enter_next_block([signed_kind, signed_kind], args_gv)
+        [gv_a, gv_b] = args_gv
+
+        gv_result = builder.genop2("int_add", gv_a, gv_b)
+
+        builder.finish_and_return(sigtoken, gv_result)
+
+        false_builder.start_writing()
+        false_builder.finish_and_goto([rgenop.genconst(2), rgenop.genconst(1)], label)
+
+        fnptr = self.cast(gv_callable, 1)
+
+        res = fnptr(20, 2)
+        assert res == 4
+
+        res = fnptr(0, 2)
+        assert res == 3
+



More information about the Pypy-commit mailing list