Author: Carl Friedrich Bolz <[email protected]>
Branch:
Changeset: r87129:9e6653e203d8
Date: 2016-09-16 11:38 +0200
http://bitbucket.org/pypy/pypy/changeset/9e6653e203d8/
Log: fix bug in codewriter about passing the exitswitch variable to a
call
this kind of code broke stuff: v = x is None f(v) if v: ...
because the "if v in op.args" condition didn't trigger for the call,
since call args have an indirection
diff --git a/rpython/jit/codewriter/jtransform.py
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -200,8 +200,12 @@
or v.concretetype != lltype.Bool):
return False
for op in block.operations[::-1]:
- if v in op.args:
- return False # variable is also used in cur block
+ # check if variable is used in block
+ for arg in op.args:
+ if arg == v:
+ return False
+ if isinstance(arg, ListOfKind) and v in arg.content:
+ return False
if v is op.result:
if op.opname not in ('int_lt', 'int_le', 'int_eq', 'int_ne',
'int_gt', 'int_ge',
diff --git a/rpython/jit/codewriter/test/test_jtransform.py
b/rpython/jit/codewriter/test/test_jtransform.py
--- a/rpython/jit/codewriter/test/test_jtransform.py
+++ b/rpython/jit/codewriter/test/test_jtransform.py
@@ -243,6 +243,20 @@
assert block.exitswitch == (opname, v1, '-live-before')
assert block.exits == exits
+def test_optimize_goto_if_not__argument_to_call():
+ for opname in ['ptr_iszero', 'ptr_nonzero']:
+ v1 = Variable()
+ v3 = Variable(); v3.concretetype = lltype.Bool
+ v4 = Variable()
+ block = Block([v1])
+ callop = SpaceOperation('residual_call_r_i',
+ ["fake", ListOfKind('int', [v3])], v4)
+ block.operations = [SpaceOperation(opname, [v1], v3), callop]
+ block.exitswitch = v3
+ block.exits = exits = [FakeLink(False), FakeLink(True)]
+ res = Transformer().optimize_goto_if_not(block)
+ assert not res
+
def test_symmetric():
ops = {'int_add': 'int_add',
'int_or': 'int_or',
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit