[pypy-svn] r26383 - in pypy/dist/pypy/translator: . backendopt/test
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 26 21:31:05 CEST 2006
Author: arigo
Date: Wed Apr 26 21:31:03 2006
New Revision: 26383
Modified:
pypy/dist/pypy/translator/backendopt/test/test_all.py
pypy/dist/pypy/translator/simplify.py
Log:
Bugfix in the caller of replace_exitswitch_by_constant().
Caused inlining to produce broken code in some cases.
Modified: pypy/dist/pypy/translator/backendopt/test/test_all.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_all.py (original)
+++ pypy/dist/pypy/translator/backendopt/test/test_all.py Wed Apr 26 21:31:03 2006
@@ -150,3 +150,20 @@
digest3 = md5digest(t)
assert digest1 == digest3
+
+def test_bug_inlined_if():
+ def f(x, flag):
+ if flag:
+ y = x
+ else:
+ y = x+1
+ return y*5
+ def myfunc(x):
+ return f(x, False) - f(x, True)
+
+ assert myfunc(10) == 5
+
+ t = translateopt(myfunc, [int], inline_threshold=100)
+ interp = LLInterpreter(t.rtyper)
+ res = interp.eval_graph(graphof(t, myfunc), [10])
+ assert res == 5
Modified: pypy/dist/pypy/translator/simplify.py
==============================================================================
--- pypy/dist/pypy/translator/simplify.py (original)
+++ pypy/dist/pypy/translator/simplify.py Wed Apr 26 21:31:03 2006
@@ -48,6 +48,7 @@
newexits[0].llexitcase = None
block.exitswitch = None
block.recloseblock(*newexits)
+ return newexits
# ____________________________________________________________
@@ -341,7 +342,8 @@
link.prevblock.exitswitch = newexitswitch
link.prevblock.recloseblock(*exits)
if isinstance(newexitswitch, Constant) and newexitswitch != c_last_exception:
- replace_exitswitch_by_constant(link.prevblock, newexitswitch)
+ exits = replace_exitswitch_by_constant(link.prevblock,
+ newexitswitch)
stack.extend(exits)
else:
if link.target not in seen:
More information about the Pypy-commit
mailing list