Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch: regalloc-playground
Changeset: r92328:d2f37627db2e
Date: 2017-09-05 18:33 +0200
http://bitbucket.org/pypy/pypy/changeset/d2f37627db2e/
Log: extract a series of int ops from a real trace (and implement
int_neg)
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
@@ -1000,6 +1000,7 @@
consider_cond_call_value_r = consider_cond_call
def consider_call_malloc_nursery(self, op):
+ # YYY what's the reason for using a fixed register for the result?
size_box = op.getarg(0)
assert isinstance(size_box, ConstInt)
size = size_box.getint()
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
@@ -32,18 +32,27 @@
# no hint by default
pass
+
+ def consider_int_neg(self, op, position):
+ self.longevity.try_use_same_register(op.getarg(0), op)
+ consider_int_invert = consider_int_neg
+
def _consider_binop_part(self, op, position, symm=False):
x = op.getarg(0)
y = op.getarg(1)
# For symmetrical operations, if y won't be used after the current
# operation finishes, but x will be, then swap the role of 'x' and 'y'
- if (symm and isinstance(x, ConstInt) or (
- not isinstance(y, ConstInt) and
- self.longevity[x].last_usage > position and
- self.longevity[y].last_usage == position)):
- x, y = y, x
- self.longevity.try_use_same_register(x, op)
+ if symm:
+ if isinstance(x, Const):
+ x, y = y, x
+ elif (not isinstance(y, Const) and
+ self.longevity[x].last_usage > position and
+ self.longevity[y].last_usage == position):
+ x, y = y, x
+
+ if not isinstance(x, Const):
+ self.longevity.try_use_same_register(x, op)
def _consider_binop(self, op, position):
self._consider_binop_part(op, position)
@@ -89,8 +98,8 @@
self.longevity.fixed_register(position, ecx, op)
self.longevity.fixed_register(position, edx)
- #consider_call_malloc_nursery_varsize = consider_call_malloc_nursery
- #consider_call_malloc_nursery_varsize_frame = consider_call_malloc_nursery
+ consider_call_malloc_nursery_varsize = consider_call_malloc_nursery
+ consider_call_malloc_nursery_varsize_frame = consider_call_malloc_nursery
def _call(self, op, position, args, save_all_regs=False):
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
@@ -226,3 +226,36 @@
# 2 moves, because the call_malloc_nursery hints prevent using ecx and
# edx for any of the integer results
assert len(self.filter_log_moves()) == 2
+
+ def test_flowcontext(self):
+ # real index manipulation for a slicing operation done when translating
+ # on top of pypy
+ ops = """
+ [i1, i2]
+ i3 = int_and(i1, 255)
+ i4 = int_rshift(i1, 8)
+ i5 = int_and(i4, 255)
+ i6 = int_lt(0, i5)
+ guard_false(i6) [i1]
+ i7 = int_eq(i3, 0)
+ guard_false(i7) [i1]
+ i8 = int_neg(i3)
+ i9 = int_lt(i8, 0)
+ guard_true(i9) [i1]
+ i10 = int_lt(i2, 0)
+ guard_false(i10) [i1]
+ i11 = int_add(i8, i2)
+ i12 = int_lt(i11, 0)
+ guard_false(i12) [i1]
+ i13 = int_gt(i11, i2)
+ guard_false(i13) [i1]
+ i14 = int_sub(i2, i11)
+ i15 = int_is_zero(i14)
+ guard_false(i15) [i1]
+ # this simulates the arraycopy call
+ i16 = call_i(ConstClass(f2ptr), i11, i14, descr=f2_calldescr)
+ finish(i16)
+ """
+ self.interpret(ops, [0], run=False)
+ # 4 moves, three for args, one for result
+ assert len(self.filter_log_moves()) == 4
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit