Commits

Michael Pavone committed 2c874a4 Draft

Make uint_le propagate integer bounds

  • Participants
  • Parent commits 1da9e8a

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/intbounds.py

             else:
                 self.make_int_gt(op.getarg(0), op.getarg(1))
 
+    def propagate_bounds_UINT_LE(self, op):
+        r = self.getvalue(op.result)
+        if r.is_constant():
+            if r.box.same_constant(CONST_1):
+                self.make_uint_le(op.getarg(0), op.getarg(1))
+            else:
+                self.make_uint_gt(op.getarg(0), op.getarg(1))
+
     def propagate_bounds_INT_GE(self, op):
         r = self.getvalue(op.result)
         if r.is_constant():

pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py

         guard_true(i6) []
         i7 = uint_gt(i0, 2)
         guard_true(i7) []
-        i8 = uint_gt(i0, 7)
+        i8 = uint_gt(i0, 6)
         guard_true(i8) []
-        i9 = uint_gt(i0, 6)
+        i9 = uint_gt(i0, 5)
         guard_true(i9) []
         i10 = uint_le(i0, 2)
         guard_false(i10) []
+        i11 = uint_le(i0, 8)
+        guard_true(i11) []
+        i12 = uint_ge(i0, 9)
+        guard_false(i12) []
         jump()
         """
         expected = """
         guard_true(i1) []
         i6 = uint_ge(i0, 5)
         guard_true(i6) []
-        i8 = uint_gt(i0, 7)
+        i8 = uint_gt(i0, 6)
         guard_true(i8) []
+        i11 = uint_le(i0, 8)
+        guard_true(i11) []
         jump()
         """
         self.optimize_loop(ops, expected)