[pypy-svn] r74829 - in pypy/trunk/pypy/objspace/flow: . test
arigo at codespeak.net
arigo at codespeak.net
Fri May 28 02:02:46 CEST 2010
Author: arigo
Date: Fri May 28 02:02:44 2010
New Revision: 74829
Modified:
pypy/trunk/pypy/objspace/flow/flowcontext.py
pypy/trunk/pypy/objspace/flow/test/test_unroll.py
Log:
Test and fix for using the same unrolling_iterable twice
in two nested loops.
Modified: pypy/trunk/pypy/objspace/flow/flowcontext.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/flowcontext.py (original)
+++ pypy/trunk/pypy/objspace/flow/flowcontext.py Fri May 28 02:02:44 2010
@@ -388,11 +388,14 @@
def replace_in_stack(self, oldvalue, newvalue):
w_new = Constant(newvalue)
stack_items_w = self.crnt_frame.valuestack_w
- for i in range(self.crnt_frame.valuestackdepth):
+ for i in range(self.crnt_frame.valuestackdepth-1, -1, -1):
w_v = stack_items_w[i]
if isinstance(w_v, Constant):
if w_v.value is oldvalue:
+ # replace the topmost item of the stack that is equal
+ # to 'oldvalue' with 'newvalue'.
stack_items_w[i] = w_new
+ break
class FlowSpaceFrame(pyframe.PyFrame):
"""
Modified: pypy/trunk/pypy/objspace/flow/test/test_unroll.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/test/test_unroll.py (original)
+++ pypy/trunk/pypy/objspace/flow/test/test_unroll.py Fri May 28 02:02:44 2010
@@ -64,3 +64,15 @@
'ne': 1,
'gt': 1,
'ge': 1}
+
+ def test_unroll_twice(self):
+ operations = unrolling_iterable([1, 2, 3])
+ def f(x):
+ for num1 in operations:
+ for num2 in operations:
+ x = x + (num1 + num2)
+ return x
+
+ graph = self.codetest(f)
+ ops = self.all_operations(graph)
+ assert ops['add'] == 9
More information about the Pypy-commit
mailing list