[pypy-commit] pypy ssa-flow: optimise remove_trivial_links()

rlamy noreply at buildbot.pypy.org
Fri Nov 14 19:06:37 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: ssa-flow
Changeset: r74526:5ad8e04f2740
Date: 2014-11-14 04:48 +0000
http://bitbucket.org/pypy/pypy/changeset/5ad8e04f2740/

Log:	optimise remove_trivial_links()

diff --git a/rpython/flowspace/model.py b/rpython/flowspace/model.py
--- a/rpython/flowspace/model.py
+++ b/rpython/flowspace/model.py
@@ -206,8 +206,6 @@
         return uniqueitems([w for w in result if isinstance(w, Constant)])
 
     def renamevariables(self, mapping):
-        for a in mapping:
-            assert isinstance(a, Variable), a
         self.inputargs = [mapping.get(a, a) for a in self.inputargs]
         for op in self.operations:
             op.args = [mapping.get(a, a) for a in op.args]
diff --git a/rpython/translator/simplify.py b/rpython/translator/simplify.py
--- a/rpython/translator/simplify.py
+++ b/rpython/translator/simplify.py
@@ -270,10 +270,15 @@
                 while vprev in renaming:
                     vprev = renaming[vprev]
                 renaming[vtarg] = vprev
-            target.renamevariables(renaming)
-            source.operations.extend(target.operations)
-            source.exitswitch = newexitswitch = target.exitswitch
-            exits = target.exits
+            def rename(v):
+                return renaming.get(v, v)
+            for op in target.operations:
+                source.operations.append(op.replace(renaming))
+            source.exitswitch = newexitswitch = rename(target.exitswitch)
+            exits = []
+            for exit in target.exits:
+                newexit = exit.copy(rename)
+                exits.append(newexit)
             source.recloseblock(*exits)
             if isinstance(newexitswitch, Constant) and newexitswitch != c_last_exception:
                 exits = replace_exitswitch_by_constant(source, newexitswitch)


More information about the pypy-commit mailing list