Author: Squeaky <squeaky...@gmx.com> Branch: optimize-int-and Changeset: r69175:caba2738c3ab Date: 2014-02-16 15:56 +0100 http://bitbucket.org/pypy/pypy/changeset/caba2738c3ab/
Log: fix another test, make optimization symetric diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py --- a/rpython/jit/metainterp/optimizeopt/rewrite.py +++ b/rpython/jit/metainterp/optimizeopt/rewrite.py @@ -86,15 +86,21 @@ v2 = self.getvalue(op.getarg(1)) if v1.is_null() or v2.is_null(): self.make_constant_int(op.result, 0) + return elif v2.is_constant(): val = v2.box.getint() - if val == -1 or v1.intbound.lower >= 0 and \ - v1.intbound.upper <= val & ~(val + 1): + if val == -1 or v1.intbound.lower >= 0 \ + and v1.intbound.upper <= val & ~(val + 1): self.make_equal_to(op.result, v1) - else: - self.emit_operation(op) - else: - self.emit_operation(op) + return + elif v1.is_constant(): + val = v1.box.getint() + if val == -1 or v2.intbound.lower >= 0 \ + and v2.intbound.upper <= val & ~(val + 1): + self.make_equal_to(op.result, v2) + return + + self.emit_operation(op) def optimize_INT_OR(self, op): v1 = self.getvalue(op.getarg(0)) diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py --- a/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py +++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizeopt.py @@ -4753,7 +4753,8 @@ def test_bound_and(self): ops = """ - [i0] + [] + i0 = escape() i1 = int_and(i0, 255) i2 = int_lt(i1, 500) guard_true(i2) [] @@ -4779,10 +4780,11 @@ guard_true(i14) [] i15 = int_ge(i1, 20) guard_true(i15) [] - jump(i1) - """ - expected = """ - [i0] + jump() + """ + expected = """ + [] + i0 = escape() i1 = int_and(i0, 255) i12 = int_lt(i1, 100) guard_true(i12) [] @@ -4792,7 +4794,7 @@ guard_true(i14) [] i15 = int_ge(i1, 20) guard_true(i15) [] - jump(i1) + jump() """ self.optimize_loop(ops, expected) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit