Commits

Michael Pavone committed 1da9e8a Draft

Extend boundary check optimizations to uint_le

  • Participants
  • Parent commits c5a2f28

Comments (0)

Files changed (2)

File pypy/jit/metainterp/optimizeopt/intbounds.py

     def optimize_UINT_LE(self, op):
         v1 = self.getvalue(op.getarg(0))
         v2 = self.getvalue(op.getarg(1))
+        zero = IntBound(0, 0)
         if v1 is v2:
             self.make_constant_int(op.result, 1)
+        elif v1.intbound.known_ge(zero) and v2.intbound.known_ge(zero):
+            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)
+            else:
+                self.emit_operation(op)
         else:
             self.emit_operation(op)
 

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

         guard_true(i8) []
         i9 = uint_gt(i0, 6)
         guard_true(i9) []
+        i10 = uint_le(i0, 2)
+        guard_false(i10) []
         jump()
         """
         expected = """