Commits

Michael Pavone committed c5a2f28 Draft

Make uint_ge and uint_gt propagate integer bounds

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/intbounds.py

     def make_int_gt(self, box1, box2):
         self.make_int_lt(box2, box1)
 
+    def make_uint_gt(self, box1, box2):
+        self.make_uint_lt(box2, box1)
+
     def make_int_ge(self, box1, box2):
         self.make_int_le(box2, box1)
 
             else:
                 self.make_int_le(op.getarg(0), op.getarg(1))
 
+    def propagate_bounds_UINT_GT(self, op):
+        r = self.getvalue(op.result)
+        if r.is_constant():
+            if r.box.same_constant(CONST_1):
+                self.make_uint_gt(op.getarg(0), op.getarg(1))
+            else:
+                self.make_uint_le(op.getarg(0), op.getarg(1))
+
     def propagate_bounds_INT_LE(self, op):
         r = self.getvalue(op.result)
         if r.is_constant():
             else:
                 self.make_int_lt(op.getarg(0), op.getarg(1))
 
+    def propagate_bounds_UINT_GE(self, op):
+        r = self.getvalue(op.result)
+        if r.is_constant():
+            if r.box.same_constant(CONST_1):
+                self.make_uint_ge(op.getarg(0), op.getarg(1))
+            else:
+                self.make_uint_lt(op.getarg(0), op.getarg(1))
+
     def propagate_bounds_INT_EQ(self, op):
         r = self.getvalue(op.result)
         if r.is_constant():

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

         guard_false(i4) []
         i5 = uint_gt(i0, 12)
         guard_false(i5) []
+        i6 = uint_ge(i0, 5)
+        guard_true(i6) []
+        i7 = uint_gt(i0, 2)
+        guard_true(i7) []
+        i8 = uint_gt(i0, 7)
+        guard_true(i8) []
+        i9 = uint_gt(i0, 6)
+        guard_true(i9) []
         jump()
         """
         expected = """
         i0 = escape()
         i1 = uint_lt(i0, 10)
         guard_true(i1) []
+        i6 = uint_ge(i0, 5)
+        guard_true(i6) []
+        i8 = uint_gt(i0, 7)
+        guard_true(i8) []
         jump()
         """
         self.optimize_loop(ops, expected)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.