Author: Carl Friedrich Bolz <[email protected]>
Branch: better-storesink
Changeset: r87172:50199f21c3b9
Date: 2016-09-16 14:54 +0200
http://bitbucket.org/pypy/pypy/changeset/50199f21c3b9/
Log: be more careful about merging value, never make the results of
find_rep the result of the merge. it's only for keys. add that as a
comment.
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
@@ -53,6 +53,14 @@
self.heapcache.copy())
def _var_rep(self, var):
+ # return the representative variable for var. All variables that must
+ # be equal to each other always have the same representative. The
+ # representative's definition dominates the use of all variables that
+ # it represents. casted pointers are considered the same objects.
+ # NB: it's very important to use _var_rep only when computing keys in
+ # the *cache dictionaries, never to actually put any new variable into
+ # the graph, because the concretetypes can change when calling
+ # _var_rep.
var = self.new_unions.find_rep(var)
return self.variable_families.find_rep(var)
@@ -75,10 +83,10 @@
break
else:
# all the same!
- return first, False
+ return results[0], False
if newres is None:
newres = Variable()
- newres.concretetype = first.concretetype
+ newres.concretetype = results[0].concretetype
return newres, True
def _merge_results(self, tuples, results, backedges):
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
@@ -520,3 +520,9 @@
assert not needs_adding
assert res == c1
+ # different vars, but same reps, 2
+ reps = {v2: v1}
+ res, needs_adding = c._find_new_res([v2, v2])
+ assert not needs_adding
+ assert res is v2
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit