aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2020-04-29 10:37:57 +0200
committerCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2020-04-29 10:37:57 +0200
commit80f5899271e09ed0a4777b28202b5c4011c67c0c (patch)
tree38e921cd02d2de0db8a38a24e1d5722cfa1cadff
parentfix test_ast. (diff)
downloadpypy-80f5899271e09ed0a4777b28202b5c4011c67c0c.tar.gz
pypy-80f5899271e09ed0a4777b28202b5c4011c67c0c.tar.bz2
pypy-80f5899271e09ed0a4777b28202b5c4011c67c0c.zip
express the make_le/ge/gt/lt methods in terms of their _const variants
-rw-r--r--rpython/jit/metainterp/optimizeopt/intutils.py40
1 files changed, 32 insertions, 8 deletions
diff --git a/rpython/jit/metainterp/optimizeopt/intutils.py b/rpython/jit/metainterp/optimizeopt/intutils.py
index a63af3df3c..22de4958a8 100644
--- a/rpython/jit/metainterp/optimizeopt/intutils.py
+++ b/rpython/jit/metainterp/optimizeopt/intutils.py
@@ -42,28 +42,50 @@ class IntBound(AbstractInfo):
# Returns True if the bound was updated
def make_le(self, other):
if other.has_upper:
+ return self.make_le_const(other.upper)
if not self.has_upper or other.upper < self.upper:
self.has_upper = True
self.upper = other.upper
return True
return False
+ def make_le_const(self, other):
+ if not self.has_upper or other < self.upper:
+ self.has_upper = True
+ self.upper = other
+ return True
+ return False
+
def make_lt(self, other):
- return self.make_le(other.add(-1))
+ if other.has_upper:
+ return self.make_lt_const(other.upper)
+ return False
+
+ def make_lt_const(self, other):
+ try:
+ other = ovfcheck(other - 1)
+ except OverflowError:
+ return False
+ return self.make_le_const(other)
def make_ge(self, other):
if other.has_lower:
- if not self.has_lower or other.lower > self.lower:
- self.has_lower = True
- self.lower = other.lower
- return True
+ return self.make_ge_const(other.lower)
return False
def make_ge_const(self, other):
- return self.make_ge(ConstIntBound(other))
+ if not self.has_lower or other > self.lower:
+ self.has_lower = True
+ self.lower = other
+ return True
+ return False
def make_gt_const(self, other):
- return self.make_gt(ConstIntBound(other))
+ try:
+ other = ovfcheck(other + 1)
+ except OverflowError:
+ return False
+ return self.make_ge_const(other)
def make_eq_const(self, intval):
self.has_upper = True
@@ -72,7 +94,9 @@ class IntBound(AbstractInfo):
self.lower = intval
def make_gt(self, other):
- return self.make_ge(other.add(1))
+ if other.has_lower:
+ return self.make_gt_const(other.lower)
+ return False
def is_constant(self):
return self.has_upper and self.has_lower and self.lower == self.upper