1. Pypy
  2. Untitled project
  3. pypy

Commits

Carl Friedrich Bolz  committed e43da5c

yay, another completely untested case:
match a value with an intbound against a constant

  • Participants
  • Parent commits aef8600
  • Branches small-unroll-improvements

Comments (0)

Files changed (2)

File rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py

View file
  • Ignore whitespace
         self.guards(info1, info2, value1, expected)
         self.check_invalid(info1, info2, BoxInt(50))
 
+    def test_intbounds_constant(self):
+        value1 = OptValue(BoxInt(15))
+        value1.intbound.make_ge(IntBound(0, 10))
+        value1.intbound.make_le(IntBound(20, 30))
+        info1 = NotVirtualStateInfo(value1)
+        info2 = NotVirtualStateInfo(OptValue(ConstInt(10000)))
+        self.check_invalid(info1, info2)
+        info1 = NotVirtualStateInfo(value1)
+        info2 = NotVirtualStateInfo(OptValue(ConstInt(11)))
+        self.check_no_guards(info1, info2)
 
     def test_known_class(self):
         value1 = OptValue(self.nodebox)

File rpython/jit/metainterp/optimizeopt/virtualstate.py

View file
  • Ignore whitespace
             raise VirtualStatesCantMatch("length bound does not match")
 
         if self.level == LEVEL_UNKNOWN:
-            if other.level == LEVEL_UNKNOWN:
-                return self._generate_guards_intbounds(other, box, extra_guards)
-            else:
-                return # matches everything
+            # confusingly enough, this is done also for pointers
+            # which have the full range as the "bound", so it always works
+            return self._generate_guards_intbounds(other, box, extra_guards)
 
         # the following conditions often peek into the runtime value that the
         # box had when tracing. This value is only used as an educated guess.
     def _generate_guards_intbounds(self, other, box, extra_guards):
         if self.intbound.contains_bound(other.intbound):
             return
-        if (isinstance(box, BoxInt) and
+        if (box is not None and isinstance(box, BoxInt) and
                 self.intbound.contains(box.getint())):
             # this may generate a few more guards than needed, but they are
             # optimized away when emitting them