Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: better-storesink
Changeset: r87165:8999d5b9bffd
Date: 2016-09-12 19:33 +0200
http://bitbucket.org/pypy/pypy/changeset/8999d5b9bffd/

Log:    fix immutable checks

diff --git a/rpython/translator/backendopt/cse.py 
b/rpython/translator/backendopt/cse.py
--- a/rpython/translator/backendopt/cse.py
+++ b/rpython/translator/backendopt/cse.py
@@ -217,7 +217,7 @@
                 res = None
                 if isinstance(arg0, Constant):
                     PTRTYPE = arg0.concretetype.TO
-                    if PTRTYPE._immutable_field(fieldname).is_immutable:
+                    if PTRTYPE._immutable_field(fieldname):
                         # can constant-fold:
                         FIELDTYPE = getattr(PTRTYPE, fieldname)
                         value = getattr(arg0.value, fieldname)
diff --git a/rpython/translator/backendopt/test/test_cse.py 
b/rpython/translator/backendopt/test/test_cse.py
--- a/rpython/translator/backendopt/test/test_cse.py
+++ b/rpython/translator/backendopt/test/test_cse.py
@@ -388,6 +388,20 @@
             return a2.a
         self.check(read, [int], getfield=0)
 
+        # not immutable
+        class A(object):
+            def __init__(self, a):
+                self.a = a
+        a1 = A(5)
+        a2 = A(8)
+
+        def read(i):
+            if i:
+                return a1.a
+            return a2.a
+        self.check(read, [int], getfield=2)
+
+
 
 def fakevar(name='v'):
     var = Variable(name)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to