aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'rpython/jit/metainterp/optimizeopt/intutils.py')
-rw-r--r--rpython/jit/metainterp/optimizeopt/intutils.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/rpython/jit/metainterp/optimizeopt/intutils.py b/rpython/jit/metainterp/optimizeopt/intutils.py
index cbe10face6..9f2ced0f00 100644
--- a/rpython/jit/metainterp/optimizeopt/intutils.py
+++ b/rpython/jit/metainterp/optimizeopt/intutils.py
@@ -309,6 +309,36 @@ class IntBound(AbstractInfo):
r.make_ge_const(0)
return r
+ def invert_bound(self):
+ res = self.clone()
+ res.has_upper = False
+ if self.has_lower:
+ res.upper = ~self.lower
+ res.has_upper = True
+ res.has_lower = False
+ if self.has_upper:
+ res.lower = ~self.upper
+ res.has_lower = True
+ return res
+
+ def neg_bound(self):
+ res = self.clone()
+ res.has_upper = False
+ if self.has_lower:
+ try:
+ res.upper = ovfcheck(-self.lower)
+ res.has_upper = True
+ except OverflowError:
+ pass
+ res.has_lower = False
+ if self.has_upper:
+ try:
+ res.lower = ovfcheck(-self.upper)
+ res.has_lower = True
+ except OverflowError:
+ pass
+ return res
+
def contains(self, val):
if not we_are_translated():
assert not isinstance(val, long)