[pypy-commit] pypy vecopt: remember expansion (reduces register pressure if constant/variable is use more often). but not for heterogeneous expanded vectors, I don't think this happens frequently
plan_rich
noreply at buildbot.pypy.org
Wed Jun 3 08:53:07 CEST 2015
Author: Richard Plangger <rich at pasra.at>
Branch: vecopt
Changeset: r77799:95db7332c363
Date: 2015-06-03 08:53 +0200
http://bitbucket.org/pypy/pypy/changeset/95db7332c363/
Log: remember expansion (reduces register pressure if constant/variable
is use more often). but not for heterogeneous expanded vectors, I
don't think this happens frequently
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_schedule.py
@@ -108,6 +108,7 @@
v2[i64#2] = vec_int_pack(v1[i64#2], i0, 0, 1)
v3[i64#2] = vec_int_pack(v2[i64#2], i1, 1, 1)
v4[i64#2] = vec_int_expand(73)
+ #
v5[i64#2] = vec_int_add(v3[i64#2], v4[i64#2])
""", False)
self.assert_equal(loop2, loop3)
@@ -123,6 +124,28 @@
v2[f64#2] = vec_float_pack(v1[f64#2], f0, 0, 1)
v3[f64#2] = vec_float_pack(v2[f64#2], f1, 1, 1)
v4[f64#2] = vec_float_expand(73.0)
+ #
v5[f64#2] = vec_float_add(v3[f64#2], v4[f64#2])
""", False)
self.assert_equal(loop2, loop3)
+
+ def test_scalar_remember_expansion(self):
+ loop1 = self.parse("""
+ f10 = float_add(f0, f5)
+ f11 = float_add(f1, f5)
+ f12 = float_add(f10, f5)
+ f13 = float_add(f11, f5)
+ """)
+ pack1 = self.pack(loop1, 0, 2)
+ pack2 = self.pack(loop1, 2, 4)
+ loop2 = self.schedule(loop1, [pack1, pack2], prepend_invariant=True)
+ loop3 = self.parse("""
+ v1[f64#2] = vec_box(2)
+ v2[f64#2] = vec_float_pack(v1[f64#2], f0, 0, 1)
+ v3[f64#2] = vec_float_pack(v2[f64#2], f1, 1, 1)
+ v4[f64#2] = vec_float_expand(f5) # only expaned once
+ #
+ v5[f64#2] = vec_float_add(v3[f64#2], v4[f64#2])
+ v6[f64#2] = vec_float_add(v5[f64#2], v4[f64#2])
+ """, False)
+ self.assert_equal(loop2, loop3)
diff --git a/rpython/jit/metainterp/optimizeopt/vectorize.py b/rpython/jit/metainterp/optimizeopt/vectorize.py
--- a/rpython/jit/metainterp/optimizeopt/vectorize.py
+++ b/rpython/jit/metainterp/optimizeopt/vectorize.py
@@ -1052,11 +1052,17 @@
def expand(self, nodes, arg, argidx):
vbox = self.input_type.new_vector_box(len(nodes))
box_type = arg.type
+ expanded_map = self.sched_data.expanded_map
invariant_ops = self.sched_data.invariant_oplist
invariant_vars = self.sched_data.invariant_vector_vars
if isinstance(arg, BoxVector):
box_type = arg.item_type
+ # note that heterogenous nodes are not yet tracked
+ already_expanded = expanded_map.get(arg, None)
+ if already_expanded:
+ return already_expanded
+
for i, node in enumerate(nodes):
op = node.getoperation()
if not arg.same_box(op.getarg(argidx)):
@@ -1069,6 +1075,7 @@
op = ResOperation(expand_opnum, [arg], vbox)
invariant_ops.append(op)
invariant_vars.append(vbox)
+ expanded_map[arg] = vbox
return vbox
op = ResOperation(rop.VEC_BOX, [ConstInt(len(nodes))], vbox)
@@ -1085,6 +1092,7 @@
op = ResOperation(opnum, [vbox,arg,ci,c1], new_box)
vbox = new_box
invariant_ops.append(op)
+
invariant_vars.append(vbox)
return vbox
@@ -1239,6 +1247,7 @@
self.vec_reg_size = vec_reg_size
self.invariant_oplist = []
self.invariant_vector_vars = []
+ self.expanded_map = {}
def as_vector_operation(self, pack):
op_count = len(pack.operations)
More information about the pypy-commit
mailing list