Commits

Alex Gaynor committed df6f7a5 Merge

mreged upstream

  • Participants
  • Parent commits b813839, 4b667c1

Comments (0)

Files changed (2)

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

-from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift
+from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT
 
 class IntBound(object):
     _attrs_ = ('has_upper', 'has_lower', 'upper', 'lower')
 
     def make_lt(self, other):
         return self.make_le(other.add(-1))
-
+ 
     def make_ge(self, other):
         if other.has_lower:
             if not self.has_lower or other.lower > self.lower:
     def lshift_bound(self, other):
         if self.has_upper and self.has_lower and \
            other.has_upper and other.has_lower and \
-           other.known_ge(IntBound(0, 0)):
+           other.known_ge(IntBound(0, 0)) and \
+           other.known_lt(IntBound(LONG_BIT, LONG_BIT)):
             try:
                 vals = (ovfcheck_lshift(self.upper, other.upper),
                         ovfcheck_lshift(self.upper, other.lower),
     def rshift_bound(self, other):
         if self.has_upper and self.has_lower and \
            other.has_upper and other.has_lower and \
-           other.known_ge(IntBound(0, 0)):
+           other.known_ge(IntBound(0, 0)) and \
+           other.known_lt(IntBound(LONG_BIT, LONG_BIT)):
             vals = (self.upper >> other.upper,
                     self.upper >> other.lower,
                     self.lower >> other.upper,

File pypy/jit/metainterp/test/test_intbound.py

      IntLowerBound, IntUnbounded
 from copy import copy
 import sys
+from pypy.rlib.rarithmetic import LONG_BIT
 
 def bound(a,b):
     if a is None and b is None:
     assert not b10.lshift_bound(b100).has_upper
     assert not bmax.lshift_bound(b10).has_upper
     assert b10.lshift_bound(b10).has_upper
+
+    for b in (b10, b100, bmax, IntBound(0, 0)):
+        for shift_count_bound in (IntBound(7, LONG_BIT), IntBound(-7, 7)):
+            #assert not b.lshift_bound(shift_count_bound).has_upper
+            assert not b.rshift_bound(shift_count_bound).has_upper
+        
     
 def test_div_bound():
     for _, _, b1 in some_bounds():