diff options
author | Carl Friedrich Bolz-Tereick <cfbolz@gmx.de> | 2021-02-04 14:23:10 +0100 |
---|---|---|
committer | Carl Friedrich Bolz-Tereick <cfbolz@gmx.de> | 2021-02-04 14:23:10 +0100 |
commit | 9e958a44ddee1c7295adb851613c3438879ac393 (patch) | |
tree | fb9ffbb9c1eb223e541797b192df44932694640b | |
parent | call more appropriate methods a bit everywhere (diff) | |
download | pypy-9e958a44ddee1c7295adb851613c3438879ac393.tar.gz pypy-9e958a44ddee1c7295adb851613c3438879ac393.tar.bz2 pypy-9e958a44ddee1c7295adb851613c3438879ac393.zip |
more of same
-rw-r--r-- | rpython/jit/metainterp/optimizeopt/intbounds.py | 6 | ||||
-rw-r--r-- | rpython/jit/metainterp/optimizeopt/intutils.py | 46 | ||||
-rw-r--r-- | rpython/jit/metainterp/optimizeopt/rewrite.py | 4 |
3 files changed, 37 insertions, 19 deletions
diff --git a/rpython/jit/metainterp/optimizeopt/intbounds.py b/rpython/jit/metainterp/optimizeopt/intbounds.py index f19989c52d..5b17728f51 100644 --- a/rpython/jit/metainterp/optimizeopt/intbounds.py +++ b/rpython/jit/metainterp/optimizeopt/intbounds.py @@ -43,8 +43,8 @@ class OptIntBounds(Optimization): # but the bounds produced by all instructions where box is # an argument might also be tighten b = self.getintbound(box) - if b.has_lower and b.has_upper and b.lower == b.upper: - self.make_constant_int(box, b.lower) + if b.is_constant(): + self.make_constant_int(box, b.getint()) box1 = self.optimizer.as_operation(box) if box1 is not None: @@ -214,7 +214,7 @@ class OptIntBounds(Optimization): # intbound.lshift_bound checks for an overflow and if the # lshift can be proven not to overflow sets b.has_upper and # b.has_lower - if b.has_lower and b.has_upper: + if b.bounded() # Synthesize the reverse op for optimize_default to reuse self.pure_from_args(rop.INT_RSHIFT, [op, arg1], arg0) diff --git a/rpython/jit/metainterp/optimizeopt/intutils.py b/rpython/jit/metainterp/optimizeopt/intutils.py index 9ce1c14393..cbe10face6 100644 --- a/rpython/jit/metainterp/optimizeopt/intutils.py +++ b/rpython/jit/metainterp/optimizeopt/intutils.py @@ -109,14 +109,34 @@ class IntBound(AbstractInfo): def bounded(self): return self.has_lower and self.has_upper + def known_lt_const(self, other): + if self.has_upper: + return self.upper < other + return False + + def known_le_const(self, other): + if self.has_upper: + return self.upper <= other + return False + + def known_gt_const(self, other): + if self.has_lower: + return self.lower > other + return False + + def known_ge_const(self, other): + if self.has_upper: + return self.upper >= other + return False + def known_lt(self, other): - if self.has_upper and other.has_lower and self.upper < other.lower: - return True + if other.has_lower: + return self.known_lt_const(other.lower) return False def known_le(self, other): - if self.has_upper and other.has_lower and self.upper <= other.lower: - return True + if other.has_lower: + return self.known_le_const(other.lower) return False def known_gt(self, other): @@ -240,10 +260,9 @@ class IntBound(AbstractInfo): return r def lshift_bound(self, other): - if self.has_upper and self.has_lower and \ - other.has_upper and other.has_lower and \ + if self.bounded() and other.bounded() and \ other.known_nonnegative() and \ - other.known_lt(IntBound(LONG_BIT, LONG_BIT)): + other.known_lt_const(LONG_BIT): try: vals = (ovfcheck(self.upper << other.upper), ovfcheck(self.upper << other.lower), @@ -256,10 +275,9 @@ class IntBound(AbstractInfo): return IntUnbounded() def rshift_bound(self, other): - if self.has_upper and self.has_lower and \ - other.has_upper and other.has_lower and \ + if self.bounded() and other.bounded() and \ other.known_nonnegative() and \ - other.known_lt(IntBound(LONG_BIT, LONG_BIT)): + other.known_lt_const(LONG_BIT): vals = (self.upper >> other.upper, self.upper >> other.lower, self.lower >> other.upper, @@ -355,7 +373,7 @@ class IntBound(AbstractInfo): def is_bool(self): return (self.bounded() and self.known_nonnegative() and - self.known_le(ConstIntBound(1))) + self.known_le_const(1)) def make_bool(self): self.intersect(IntBound(0, 1)) @@ -366,11 +384,11 @@ class IntBound(AbstractInfo): return ConstInt(self.getint()) def getnullness(self): - if self.known_gt(IntBound(0, 0)) or \ - self.known_lt(IntBound(0, 0)): + if self.known_gt_const(0) or \ + self.known_lt_const(0): return INFO_NONNULL if self.known_nonnegative() and \ - self.known_le(IntBound(0, 0)): + self.known_le_const(0): return INFO_NULL return INFO_UNKNOWN diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py b/rpython/jit/metainterp/optimizeopt/rewrite.py index bef3c84142..5139e4a7f4 100644 --- a/rpython/jit/metainterp/optimizeopt/rewrite.py +++ b/rpython/jit/metainterp/optimizeopt/rewrite.py @@ -859,7 +859,7 @@ class OptRewrite(Optimization): return True else: from rpython.jit.metainterp.optimizeopt import intdiv - known_nonneg = b1.known_ge(IntBound(0, 0)) + known_nonneg = b1.known_nonnegative() operations = intdiv.division_operations(arg1, val, known_nonneg) newop = None for newop in operations: @@ -899,7 +899,7 @@ class OptRewrite(Optimization): return True else: from rpython.jit.metainterp.optimizeopt import intdiv - known_nonneg = b1.known_ge(IntBound(0, 0)) + known_nonneg = b1.known_nonnegative() operations = intdiv.modulo_operations(arg1, val, known_nonneg) newop = None for newop in operations: |