Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: regalloc-playground
Changeset: r92324:925ba08f5490
Date: 2017-09-03 12:05 +0200
http://bitbucket.org/pypy/pypy/changeset/925ba08f5490/
Log: fix bug for a call argument appearing twice
diff --git a/rpython/jit/backend/x86/reghint.py
b/rpython/jit/backend/x86/reghint.py
--- a/rpython/jit/backend/x86/reghint.py
+++ b/rpython/jit/backend/x86/reghint.py
@@ -167,24 +167,28 @@
def hint(self, position, args, argtypes, save_all_regs):
hinted_xmm = []
hinted_gpr = []
+ hinted_args = []
for i in range(len(args)):
arg = args[i]
if arg.type == "f":
tgt = self._unused_xmm()
- if tgt is not None and not arg.is_constant():
+ if tgt is not None and not arg.is_constant() and arg not in
hinted_args:
self.longevity.fixed_register(position, tgt, arg)
hinted_xmm.append(tgt)
+ hinted_args.append(arg)
elif i < len(argtypes) and argtypes[i] == 'S':
# Singlefloat argument
tgt = self._unused_xmm()
- if tgt is not None and not arg.is_constant():
+ if tgt is not None and not arg.is_constant() and arg not in
hinted_args:
self.longevity.fixed_register(position, tgt, arg)
hinted_xmm.append(tgt)
+ hinted_args.append(arg)
else:
tgt = self._unused_gpr()
- if tgt is not None and not arg.is_constant():
+ if tgt is not None and not arg.is_constant() and arg not in
hinted_args:
self.longevity.fixed_register(position, tgt, arg)
hinted_gpr.append(tgt)
+ hinted_args.append(arg)
# block all remaining registers that are not caller save
# XXX the case save_all_regs == 1 (save callee-save regs + gc ptrs) is
# no expressible atm
diff --git a/rpython/jit/backend/x86/test/test_regalloc.py
b/rpython/jit/backend/x86/test/test_regalloc.py
--- a/rpython/jit/backend/x86/test/test_regalloc.py
+++ b/rpython/jit/backend/x86/test/test_regalloc.py
@@ -97,6 +97,22 @@
# i0 and i1, one for the result to the stack
assert len([entry for entry in self.log if entry.name == "mov"]) == 3
+ def test_call_use_argument_twice(self):
+ ops = '''
+ [i0, i1, i2, i3]
+ i7 = int_add(i0, i1)
+ i8 = int_add(i2, 13)
+ i9 = call_i(ConstClass(f2ptr), i7, i7, descr=f2_calldescr)
+ i10 = int_is_true(i9)
+ guard_true(i10) [i8]
+ finish(i9)
+ '''
+ self.interpret(ops, [5, 6, 7, 8])
+ # two moves are needed from the stack frame to registers for arguments
+ # i0 and i1, one for the result to the stack
+ # one for the copy to the other argument register
+ assert len([entry for entry in self.log if entry.name == "mov"]) == 4
+
@pytest.mark.skip("later")
def test_same_stack_entry_many_times(self):
ops = '''
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit