Michael Pavone avatar Michael Pavone committed 9fd1c9e Draft

Refactor redundant uint compare test into 4 smaller tests that are easier to understand

Comments (0)

Files changed (1)

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

         jump()
         """
         self.optimize_loop(ops, expected)
-
-    def test_redundant_compare_uint(self):
+    
+    def test_redundant_lt_uint(self):
         ops = """
         []
         i0 = escape()
         i1 = uint_lt(i0, 10)
         guard_true(i1) []
-        i3 = uint_lt(i0, 20)
-        guard_true(i3) []
-        i4 = uint_ge(i0, 11)
-        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, 6)
-        guard_true(i8) []
-        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) []
+        i2 = uint_lt(i0, 20)
+        guard_true(i2) []
         jump()
         """
         expected = """
         i0 = escape()
         i1 = uint_lt(i0, 10)
         guard_true(i1) []
-        i6 = uint_ge(i0, 5)
-        guard_true(i6) []
-        i8 = uint_gt(i0, 6)
-        guard_true(i8) []
-        i11 = uint_le(i0, 8)
-        guard_true(i11) []
+        jump()
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_redundant_le_uint(self):
+        ops = """
+        []
+        i0 = escape()
+        i1 = uint_le(i0, 10)
+        guard_true(i1) []
+        i2 = uint_le(i0, 20)
+        guard_true(i2) []
+        jump()
+        """
+        expected = """
+        []
+        i0 = escape()
+        i1 = uint_le(i0, 10)
+        guard_true(i1) []
+        jump()
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_redundant_gt_uint(self):
+        ops = """
+        []
+        i0 = escape()
+        i1 = uint_lt(i0, 20)
+        guard_true(i1) []
+        i2 = uint_gt(i0, 10)
+        guard_true(i2) []
+        i3 = uint_gt(i0, 5)
+        guard_true(i3) []
+        jump()
+        """
+        expected = """
+        []
+        i0 = escape()
+        i1 = uint_lt(i0, 20)
+        guard_true(i1) []
+        i2 = uint_gt(i0, 10)
+        guard_true(i2) []
+        jump()
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_redundant_ge_uint(self):
+        ops = """
+        []
+        i0 = escape()
+        i1 = uint_lt(i0, 20)
+        guard_true(i1) []
+        i2 = uint_ge(i0, 10)
+        guard_true(i2) []
+        i3 = uint_ge(i0, 5)
+        guard_true(i3) []
+        jump()
+        """
+        expected = """
+        []
+        i0 = escape()
+        i1 = uint_lt(i0, 20)
+        guard_true(i1) []
+        i2 = uint_ge(i0, 10)
+        guard_true(i2) []
         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.