[pypy-svn] r62714 - in pypy/trunk/pypy/translator/backendopt: . test

arigo at codespeak.net arigo at codespeak.net
Sat Mar 7 16:25:46 CET 2009


Author: arigo
Date: Sat Mar  7 16:25:45 2009
New Revision: 62714

Modified:
   pypy/trunk/pypy/translator/backendopt/constfold.py
   pypy/trunk/pypy/translator/backendopt/test/test_constfold.py
Log:
Test and fix.


Modified: pypy/trunk/pypy/translator/backendopt/constfold.py
==============================================================================
--- pypy/trunk/pypy/translator/backendopt/constfold.py	(original)
+++ pypy/trunk/pypy/translator/backendopt/constfold.py	Sat Mar  7 16:25:45 2009
@@ -241,7 +241,7 @@
         vexit = block.exitswitch
         if isinstance(vexit, Variable):
             for link in block.exits:
-                if vexit in link.args:
+                if vexit in link.args and link.exitcase != 'default':
                     remap = {vexit: Constant(link.llexitcase,
                                              vexit.concretetype)}
                     link.args = [remap.get(v, v) for v in link.args]

Modified: pypy/trunk/pypy/translator/backendopt/test/test_constfold.py
==============================================================================
--- pypy/trunk/pypy/translator/backendopt/test/test_constfold.py	(original)
+++ pypy/trunk/pypy/translator/backendopt/test/test_constfold.py	Sat Mar  7 16:25:45 2009
@@ -317,3 +317,21 @@
     check_graph(graph, [2], 0, t)
     check_graph(graph, [10], 100, t)
     check_graph(graph, [42], 0, t)
+
+def test_merge_if_blocks_bug():
+    def fn(n):
+        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, [int])
+    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, [4], -123, t)
+    check_graph(graph, [9], 9, t)



More information about the Pypy-commit mailing list