[pypy-svn] pypy jit-short_from_state: CALL_LOOPINVARIANT support
hakanardo
commits-noreply at bitbucket.org
Fri Apr 22 15:10:15 CEST 2011
Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short_from_state
Changeset: r43534:7f7eb269501f
Date: 2011-04-22 10:47 +0200
http://bitbucket.org/pypy/pypy/changeset/7f7eb269501f/
Log: CALL_LOOPINVARIANT support
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -1282,8 +1282,8 @@
return x
res = self.meta_interp(f, [299], listops=True)
assert res == f(299)
- self.check_loops(guard_class=0, guard_value=2)
- self.check_loops(guard_class=0, guard_value=5, everywhere=True)
+ self.check_loops(guard_class=0, guard_value=3)
+ self.check_loops(guard_class=0, guard_value=6, everywhere=True)
def test_merge_guardnonnull_guardclass(self):
from pypy.rlib.objectmodel import instantiate
@@ -1437,8 +1437,8 @@
y.v = g(y.v) - y.v/y.v + lc/l[0] - 1
return y.v
res = self.meta_interp(f, [20], listops=True)
- self.check_loops(getfield_gc=0, getarrayitem_gc=0)
- self.check_loops(getfield_gc=1, getarrayitem_gc=0, everywhere=True)
+ self.check_loops(getfield_gc=1, getarrayitem_gc=0)
+ self.check_loops(getfield_gc=2, getarrayitem_gc=0, everywhere=True)
def test_guard_isnull_nonnull(self):
myjitdriver = JitDriver(greens = [], reds = ['x', 'res'])
diff --git a/pypy/jit/metainterp/optimizeopt/rewrite.py b/pypy/jit/metainterp/optimizeopt/rewrite.py
--- a/pypy/jit/metainterp/optimizeopt/rewrite.py
+++ b/pypy/jit/metainterp/optimizeopt/rewrite.py
@@ -14,6 +14,7 @@
"""
def __init__(self):
self.loop_invariant_results = {}
+ self.loop_invariant_producer = {}
def reconstruct_for_next_iteration(self, surviving_boxes,
optimizer, valuemap):
@@ -22,6 +23,11 @@
new.loop_invariant_results[key] = \
value.get_cloned(new, valuemap)
return new
+
+ def produce_potential_short_preamble_ops(self, potential_ops):
+ for op in self.loop_invariant_producer.values():
+ potential_ops[op.result] = op
+
def propagate_forward(self, op):
args = self.optimizer.make_args_key(op)
@@ -316,12 +322,14 @@
# expects a compile-time constant
assert isinstance(arg, Const)
key = make_hashable_int(arg.getint())
+
resvalue = self.loop_invariant_results.get(key, None)
if resvalue is not None:
self.make_equal_to(op.result, resvalue)
return
# change the op to be a normal call, from the backend's point of view
# there is no reason to have a separate operation for this
+ self.loop_invariant_producer[key] = op
op = op.copy_and_change(rop.CALL)
self.emit_operation(op)
resvalue = self.getvalue(op.result)
More information about the Pypy-commit
mailing list