[pypy-svn] pypy default: Test and implementation for "i0 > i0" and friends.
arigo
commits-noreply at bitbucket.org
Sat Mar 26 14:11:41 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r42971:b5865efaed32
Date: 2011-03-26 14:11 +0100
http://bitbucket.org/pypy/pypy/changeset/b5865efaed32/
Log: Test and implementation for "i0 > i0" and friends. Not implemented
for unsigned comparisons so far (does not seem really useful).
diff --git a/pypy/jit/metainterp/test/test_optimizeopt.py b/pypy/jit/metainterp/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/test/test_optimizeopt.py
@@ -816,6 +816,52 @@
"""
self.optimize_loop(ops, expected, preamble)
+ def test_compare_with_itself(self):
+ ops = """
+ []
+ i0 = escape()
+ i1 = int_lt(i0, i0)
+ guard_false(i1) []
+ i2 = int_le(i0, i0)
+ guard_true(i2) []
+ i3 = int_eq(i0, i0)
+ guard_true(i3) []
+ i4 = int_ne(i0, i0)
+ guard_false(i4) []
+ i5 = int_gt(i0, i0)
+ guard_false(i5) []
+ i6 = int_ge(i0, i0)
+ guard_true(i6) []
+ jump()
+ """
+ expected = """
+ []
+ i0 = escape()
+ jump()
+ """
+ self.optimize_loop(ops, expected)
+
+ def test_compare_with_itself_uint(self):
+ py.test.skip("implement me")
+ ops = """
+ []
+ i0 = escape()
+ i7 = uint_lt(i0, i0)
+ guard_false(i7) []
+ i8 = uint_le(i0, i0)
+ guard_true(i8) []
+ i9 = uint_gt(i0, i0)
+ guard_false(i9) []
+ i10 = uint_ge(i0, i0)
+ guard_true(i10) []
+ jump()
+ """
+ expected = """
+ []
+ i0 = escape()
+ jump()
+ """
+ self.optimize_loop(ops, expected)
diff --git a/pypy/jit/metainterp/optimizeopt/intbounds.py b/pypy/jit/metainterp/optimizeopt/intbounds.py
--- a/pypy/jit/metainterp/optimizeopt/intbounds.py
+++ b/pypy/jit/metainterp/optimizeopt/intbounds.py
@@ -205,7 +205,7 @@
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_lt(v2.intbound):
self.make_constant_int(op.result, 1)
- elif v1.intbound.known_ge(v2.intbound):
+ elif v1.intbound.known_ge(v2.intbound) or v1 is v2:
self.make_constant_int(op.result, 0)
else:
self.emit_operation(op)
@@ -215,7 +215,7 @@
v2 = self.getvalue(op.getarg(1))
if v1.intbound.known_gt(v2.intbound):
self.make_constant_int(op.result, 1)
- elif v1.intbound.known_le(v2.intbound):
+ elif v1.intbound.known_le(v2.intbound) or v1 is v2:
self.make_constant_int(op.result, 0)
else:
self.emit_operation(op)
@@ -223,7 +223,7 @@
def optimize_INT_LE(self, op):
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
- if v1.intbound.known_le(v2.intbound):
+ if v1.intbound.known_le(v2.intbound) or v1 is v2:
self.make_constant_int(op.result, 1)
elif v1.intbound.known_gt(v2.intbound):
self.make_constant_int(op.result, 0)
@@ -233,7 +233,7 @@
def optimize_INT_GE(self, op):
v1 = self.getvalue(op.getarg(0))
v2 = self.getvalue(op.getarg(1))
- if v1.intbound.known_ge(v2.intbound):
+ if v1.intbound.known_ge(v2.intbound) or v1 is v2:
self.make_constant_int(op.result, 1)
elif v1.intbound.known_lt(v2.intbound):
self.make_constant_int(op.result, 0)
More information about the Pypy-commit
mailing list