Author: Carl Friedrich Bolz <[email protected]>
Branch: small-unroll-improvements
Changeset: r70517:e43da5c8b730
Date: 2014-04-09 19:36 +0200
http://bitbucket.org/pypy/pypy/changeset/e43da5c8b730/
Log: yay, another completely untested case: match a value with an
intbound against a constant
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
@@ -365,6 +365,16 @@
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)
diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py
b/rpython/jit/metainterp/optimizeopt/virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py
@@ -304,10 +304,9 @@
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.
@@ -380,7 +379,7 @@
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
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit