[pypy-commit] pypy default: make the "store sink" optimization actually do store sinking

cfbolz noreply at buildbot.pypy.org
Tue Sep 23 11:46:26 CEST 2014


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r73657:2cb8ead5710a
Date: 2014-09-06 17:37 +0200
http://bitbucket.org/pypy/pypy/changeset/2cb8ead5710a/

Log:	make the "store sink" optimization actually do store sinking (so far
	it only did load forwarding)

diff --git a/rpython/translator/backendopt/storesink.py b/rpython/translator/backendopt/storesink.py
--- a/rpython/translator/backendopt/storesink.py
+++ b/rpython/translator/backendopt/storesink.py
@@ -35,8 +35,10 @@
             elif op.opname in ['setarrayitem', 'setinteriorfield']:
                 pass
             elif op.opname == 'setfield':
-                clear_cache_for(cache, op.args[0].concretetype,
-                                op.args[1].value)
+                target = op.args[0]
+                field = op.args[1].value
+                clear_cache_for(cache, target.concretetype, field)
+                cache[target, field] = op.args[2]
             elif has_side_effects(op):
                 cache = {}
             newops.append(op)
diff --git a/rpython/translator/backendopt/test/test_storesink.py b/rpython/translator/backendopt/test/test_storesink.py
--- a/rpython/translator/backendopt/test/test_storesink.py
+++ b/rpython/translator/backendopt/test/test_storesink.py
@@ -42,7 +42,7 @@
             a.x = i
             return a.x
 
-        self.check(f, [int], 1)
+        self.check(f, [int], 0)
 
     def test_simple(self):
         class A(object):
@@ -53,7 +53,7 @@
             a.x = i
             return a.x + a.x
 
-        self.check(f, [int], 1)
+        self.check(f, [int], 0)
 
     def test_irrelevant_setfield(self):
         class A(object):
@@ -67,7 +67,7 @@
             two = a.x
             return one + two
 
-        self.check(f, [int], 1)
+        self.check(f, [int], 0)
 
     def test_relevant_setfield(self):
         class A(object):
@@ -101,7 +101,7 @@
             two = a.x
             return one + two
 
-        self.check(f, [int], 1)
+        self.check(f, [int], 0)
 
     def test_subclass(self):
         class A(object):
@@ -119,7 +119,7 @@
             two = a.x
             return one + two
 
-        self.check(f, [int], 2)
+        self.check(f, [int], 1)
 
     def test_bug_1(self):
         class A(object):
@@ -133,4 +133,4 @@
                 return True
             return n
 
-        self.check(f, [int], 1)
+        self.check(f, [int], 0)


More information about the pypy-commit mailing list