Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: regalloc-playground
Changeset: r92352:d4ec0e2656cd
Date: 2017-09-08 09:25 +0200
http://bitbucket.org/pypy/pypy/changeset/d4ec0e2656cd/
Log: fix for duplicate jump args
diff --git a/rpython/jit/backend/x86/regalloc.py
b/rpython/jit/backend/x86/regalloc.py
--- a/rpython/jit/backend/x86/regalloc.py
+++ b/rpython/jit/backend/x86/regalloc.py
@@ -1340,6 +1340,7 @@
arglocs = descr._x86_arglocs
jump_op = self.final_jump_op
assert len(arglocs) == jump_op.numargs()
+ hinted = []
for i in range(jump_op.numargs()):
box = jump_op.getarg(i)
if not isinstance(box, Const):
@@ -1347,10 +1348,12 @@
if isinstance(loc, FrameLoc):
self.fm.hint_frame_pos[box] = self.fm.get_loc_index(loc)
else:
- assert isinstance(loc, RegLoc)
- self.longevity.fixed_register(
- self.final_jump_op_position,
- loc, box)
+ if box not in hinted:
+ hinted.append(box)
+ assert isinstance(loc, RegLoc)
+ self.longevity.fixed_register(
+ self.final_jump_op_position,
+ loc, box)
def consider_jump(self, op):
assembler = self.assembler
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
@@ -52,11 +52,11 @@
self._log("malloc_cond", size, "ecx") # always uses edx and ecx
def label(self):
- self._log("label")
+ self._log("label",
self._regalloc.final_jump_op.getdescr()._x86_arglocs)
return Assembler386.label(self)
def closing_jump(self, jump_target_descr):
- self._log("jump")
+ self._log("jump", self._regalloc.final_jump_op.getdescr()._x86_arglocs)
return Assembler386.closing_jump(self, jump_target_descr)
class TestCheckRegistersExplicitly(test_regalloc_integration.BaseTestRegalloc):
@@ -243,7 +243,6 @@
def test_malloc(self, monkeypatch):
ops = '''
[i0]
- label(i0, descr=targettoken)
i1 = int_add(i0, 1) # this is using ecx or edx because it fits
i6 = int_add(i0, 6) # this is using ecx or edx because it fits
i2 = int_add(i6, i1)
@@ -281,6 +280,27 @@
self.interpret(ops, [0], run=False)
assert len(self.filter_log_moves()) == 1
+ def test_jump_hinting_duplicate(self):
+ self.targettoken._ll_loop_code = 0
+ ops = '''
+ [i0]
+ i1 = int_add(i0, 1)
+ i10 = int_add(i1, 1)
+ i2 = int_add(i1, 1)
+ i3 = int_lt(i2, 20)
+ guard_true(i3) [i1, i10]
+ label(i2, i10, descr=targettoken)
+ i4 = int_add(i2, 1)
+ i11 = int_add(i4, i10)
+ i5 = int_add(i4, 1)
+ i6 = int_lt(i5, 20)
+ guard_true(i6) [i4, i11]
+ jump(i5, i5, descr=targettoken)
+ '''
+ self.interpret(ops, [0], run=False)
+ assert len(self.filter_log_moves()) == 3
+
+
def test_jump_hinting_int_add(self):
self.targettoken._ll_loop_code = 0
ops = '''
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit