[pypy-commit] pypy default: Add integer bounds to 'int_signext' results.

arigo noreply at buildbot.pypy.org
Thu Nov 27 13:46:57 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r74749:eba714c0fe25
Date: 2014-11-27 13:46 +0100
http://bitbucket.org/pypy/pypy/changeset/eba714c0fe25/

Log:	Add integer bounds to 'int_signext' results.

diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py
--- a/rpython/jit/metainterp/optimizeopt/intbounds.py
+++ b/rpython/jit/metainterp/optimizeopt/intbounds.py
@@ -342,6 +342,13 @@
         else:
             self.emit_operation(op)
 
+    def optimize_INT_SIGNEXT(self, op):
+        self.emit_operation(op)
+        v1 = self.getvalue(op.result)
+        numbits = op.getarg(1).getint() * 8
+        v1.intbound.make_ge(IntLowerBound(-(1 << (numbits - 1))))
+        v1.intbound.make_lt(IntUpperBound(1 << (numbits - 1)))
+
     def optimize_ARRAYLEN_GC(self, op):
         self.emit_operation(op)
         array = 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
@@ -5607,6 +5607,44 @@
         """
         self.optimize_loop(ops, ops, ops)
 
+    def test_bound_backpropagate_int_signext(self):
+        ops = """
+        []
+        i0 = escape()
+        i1 = int_signext(i0, 1)
+        i2 = int_eq(i0, i1)
+        guard_true(i2) []
+        i3 = int_le(i0, 127)    # implied by equality with int_signext
+        guard_true(i3) []
+        i5 = int_gt(i0, -129)   # implied by equality with int_signext
+        guard_true(i5) []
+        jump()
+        """
+        expected = """
+        []
+        i0 = escape()
+        i1 = int_signext(i0, 1)
+        i2 = int_eq(i0, i1)
+        guard_true(i2) []
+        jump()
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_bound_backpropagate_int_signext_2(self):
+        ops = """
+        []
+        i0 = escape()
+        i1 = int_signext(i0, 1)
+        i2 = int_eq(i0, i1)
+        guard_true(i2) []
+        i3 = int_le(i0, 126)    # false for i1 == 127
+        guard_true(i3) []
+        i5 = int_gt(i0, -128)   # false for i1 == -128
+        guard_true(i5) []
+        jump()
+        """
+        self.optimize_loop(ops, ops)
+
     def test_mul_ovf(self):
         ops = """
         [i0, i1]


More information about the pypy-commit mailing list