Commits

Alex Gaynor committed b93fffd

fix these tests, the resop int_mod returns a negative value for mixed operand signs.

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/intbounds.py

         if v2.is_constant():
             val = v2.box.getint()
             r = self.getvalue(op.result)
-            if val > 0:
-                r.intbound.make_ge(IntBound(0, 0))
-                r.intbound.make_lt(IntBound(val, val))
-            elif val < 0:
-                r.intbound.make_gt(IntBound(val, val))
-                r.intbound.make_le(IntBound(0, 0))
-            # No optimizations if val == 0, that should probably even be an
-            # error, that should never happen.
+            if val < 0:
+                val = -val
+            r.intbound.make_gt(IntBound(-val, -val))
+            r.intbound.make_lt(IntBound(val, val))
 
     def optimize_INT_LSHIFT(self, op):
         v1 = self.getvalue(op.getarg(0))

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

         i2 = int_mod(i0, 12)
         i3 = int_gt(i2, 12)
         guard_false(i3) []
-        i4 = int_lt(i2, 0)
+        i4 = int_lt(i2, -12)
         guard_false(i4) []
         i5 = int_mod(i1, -12)
         i6 = int_lt(i5, -12)
         guard_false(i6) []
-        i7 = int_gt(i5, 0)
+        i7 = int_gt(i5, 12)
         guard_false(i7) []
         jump(i2, i5)
         """