[pypy-svn] r64728 - in pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt: . test

arigo at codespeak.net arigo at codespeak.net
Mon Apr 27 14:54:23 CEST 2009


Author: arigo
Date: Mon Apr 27 14:54:22 2009
New Revision: 64728

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/constfold.py
   pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/test/test_constfold.py
Log:
Yet another test and fix for the 'default' case of exitswitches.


Modified: pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/constfold.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/constfold.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/constfold.py	Mon Apr 27 14:54:22 2009
@@ -91,6 +91,9 @@
             switch = constants[block.exitswitch].value
             remaining_exits = [link for link in block.exits
                                     if link.llexitcase == switch]
+            if not remaining_exits:
+                assert block.exits[-1].exitcase == 'default'
+                remaining_exits = [block.exits[-1]]
             assert len(remaining_exits) == 1
             remaining_exits[0].exitcase = None
             remaining_exits[0].llexitcase = None

Modified: pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/test/test_constfold.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/test/test_constfold.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/translator/backendopt/test/test_constfold.py	Mon Apr 27 14:54:22 2009
@@ -335,3 +335,21 @@
     constant_fold_graph(graph)
     check_graph(graph, [4], -123, t)
     check_graph(graph, [9], 9, t)
+
+def test_merge_if_blocks_bug_2():
+    def fn():
+        n = llop.same_as(lltype.Signed, 66)
+        if n == 1: return 5
+        elif n == 2: return 6
+        elif n == 3: return 8
+        elif n == 4: return -123
+        elif n == 5: return 12973
+        else: return n
+    
+    graph, t = get_graph(fn, [])
+    from pypy.translator.backendopt.removenoops import remove_same_as
+    from pypy.translator.backendopt import merge_if_blocks
+    remove_same_as(graph)
+    merge_if_blocks.merge_if_blocks_once(graph)
+    constant_fold_graph(graph)
+    check_graph(graph, [], 66, t)



More information about the Pypy-commit mailing list