[pypy-commit] pypy better-storesink: fix bug
cfbolz
pypy.commits at gmail.com
Fri Sep 16 17:13:05 EDT 2016
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: better-storesink
Changeset: r87160:f6dc12d932d9
Date: 2016-09-09 12:36 +0200
http://bitbucket.org/pypy/pypy/changeset/f6dc12d932d9/
Log: fix bug
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
@@ -62,12 +62,11 @@
inputarg = block.inputargs[argindex]
# bit slow, but probably ok
firstlinkarg = self.variable_families.find_rep(firstlink.args[argindex])
- results = []
for key, res in self.purecache.iteritems():
(opname, concretetype, args) = key
if args[0] != firstlinkarg: # XXX other args
continue
- results.append(res)
+ results = [res]
for linkindex, (link, cache) in enumerate(tuples):
if linkindex == 0:
continue
@@ -85,6 +84,7 @@
newres = res
if isinstance(res, Variable):
newres = res.copy()
+ assert len(results) == len(tuples)
for linkindex, (link, cache) in enumerate(tuples):
link.args.append(results[linkindex])
block.inputargs.append(newres)
@@ -118,12 +118,11 @@
inputarg = block.inputargs[argindex]
# bit slow, but probably ok
firstlinkarg = self.variable_families.find_rep(firstlink.args[argindex])
- results = []
for key, res in self.heapcache.iteritems():
(arg, fieldname) = key
if arg != firstlinkarg:
continue
- results.append(res)
+ results = [res]
for linkindex, (link, cache) in enumerate(tuples):
if linkindex == 0:
continue
@@ -299,6 +298,7 @@
if exit.target not in done and exit.target not in todo: # XXX
todo.append(exit.target)
caches_to_merge[exit.target].append((exit, cache))
+ simplify.transform_dead_op_vars(graph)
if added_same_as:
ssa.SSA_to_SSI(graph)
removenoops.remove_same_as(graph)
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
@@ -323,3 +323,30 @@
res += i + 1
return a + (i + 1)
self.check(f, [int], add=0)
+
+ def test_bug_2(self):
+ class A(object):
+ def getslice(self, a, b):
+ return "a" * a * b
+
+ def make(i):
+ a = A()
+ a.size = i * 12
+ a.pos = i * 54
+ return a
+
+ def read(i, num):
+ self = make(i)
+ if num < 0:
+ # read all
+ eol = self.size
+ else:
+ eol = self.pos + num
+ if eol > self.size:
+ eol = self.size
+
+ res = self.getslice(self.pos, eol - self.pos)
+ self.pos += len(res)
+ return res
+ self.check(read, [int, int])
+
More information about the pypy-commit
mailing list