Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: regalloc-playground Changeset: r92306:69fc3fac05ad Date: 2017-09-03 08:47 +0200 http://bitbucket.org/pypy/pypy/changeset/69fc3fac05ad/
Log: fix an off-by-one error in register selection diff --git a/rpython/jit/backend/llsupport/regalloc.py b/rpython/jit/backend/llsupport/regalloc.py --- a/rpython/jit/backend/llsupport/regalloc.py +++ b/rpython/jit/backend/llsupport/regalloc.py @@ -985,7 +985,7 @@ unfixed_reg = reg continue use_after = fixed_reg_pos.free_until_pos(position) - if use_after < longevityvar.last_usage_including_sharing(): + if use_after <= longevityvar.last_usage_including_sharing(): # can't fit continue assert use_after >= longevityvar.last_usage_including_sharing() diff --git a/rpython/jit/backend/llsupport/test/test_regalloc.py b/rpython/jit/backend/llsupport/test/test_regalloc.py --- a/rpython/jit/backend/llsupport/test/test_regalloc.py +++ b/rpython/jit/backend/llsupport/test/test_regalloc.py @@ -308,6 +308,17 @@ loc = longevity.try_pick_free_reg(0, b1, [r0, r1]) assert loc == r1 +def test_try_pick_free_reg_bug2(): + b0, b1, b2, b3, b4 = newboxes(0, 0, 0, 0, 0) + l0 = Lifetime(1, 2) + l1 = Lifetime(2, 4) + longevity = LifetimeManager({b0: l0, b1: l1}) + longevity.fixed_register(4, r1, b1) + + # does not fit into r0, use r1 + loc = longevity.try_pick_free_reg(0, b0, [r0, r1]) + assert loc == r0 + def test_simple_coalescing(): b0, b1, b2, b3, b4 = newboxes(0, 0, 0, 0, 0) l0 = Lifetime(0, 4) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit