Author: Richard Plangger <[email protected]>
Branch: vecopt
Changeset: r77986:f7b571afa033
Date: 2015-06-09 11:53 +0200
http://bitbucket.org/pypy/pypy/changeset/f7b571afa033/
Log: in the case #pack > 2 the accum is not split
diff --git a/rpython/jit/metainterp/optimizeopt/dependency.py
b/rpython/jit/metainterp/optimizeopt/dependency.py
--- a/rpython/jit/metainterp/optimizeopt/dependency.py
+++ b/rpython/jit/metainterp/optimizeopt/dependency.py
@@ -312,7 +312,7 @@
return None
def __repr__(self):
- return "Node(opidx: %d)"%self.opidx
+ return "Node(opidx: %d)" % self.opidx
def __ne__(self, other):
return not self.__eq__(other)
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py
b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -107,7 +107,7 @@
return PackType(INT, 8, True, 2)
elif box.type == FLOAT:
return PackType(FLOAT, 8, False, 2)
-
+ #
raise AssertionError("box %s not supported" % (box,))
def vectorbox_clone_set(box, count=-1, size=-1, type='-', clone_signed=True,
signed=False):
@@ -695,9 +695,21 @@
assert isinstance(other, Pack)
rightmost = self.operations[-1]
leftmost = other.operations[0]
- return rightmost == leftmost and \
- self.accum_variable == other.accum_variable and \
- self.accum_position == other.accum_position
+ # if it is not accumulating it is valid
+ accum = True
+ if self.is_accumulating():
+ if not other.is_accumulating():
+ accum = False
+ elif self.accum_position != other.accum_position:
+ accum = False
+ # aa
+ #else:
+ # i = self.accum_position
+ # lop = leftmost.getoperation()
+ # roper = rightmost.getoperation()
+ # if lop.getarg(i) is not roper.result:
+ # accum = False
+ return rightmost is leftmost and accum
def __repr__(self):
return "Pack(%r)" % self.operations
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py
b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_util.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py
@@ -156,6 +156,7 @@
floatarraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Float))
intarraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Signed))
int32arraydescr = cpu.arraydescrof(lltype.GcArray(rffi.INT))
+ int16arraydescr = cpu.arraydescrof(lltype.GcArray(rffi.SHORT))
uintarraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Unsigned))
chararraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Char))
singlefloatarraydescr =
cpu.arraydescrof(lltype.GcArray(lltype.SingleFloat))
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
b/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_vectorize.py
@@ -1069,6 +1069,25 @@
assert opt.loop.inputargs[2] in opt.packset.accum_vars
self.debug_print_operations(opt.loop)
+ def test_accumulate_int16(self):
+ trace = """
+ [p3, i4, p1, i5, i6, i7, i8]
+ guard_early_exit() [p1, i4, i5, i6, p3]
+ i9 = raw_load(i7, i5, descr=int16arraydescr)
+ guard_not_invalidated() [p1, i9, i4, i5, i6, p3]
+ i10 = int_add(i6, i9)
+ i12 = int_add(i4, 1)
+ i14 = int_add(i5, 2)
+ i15 = int_ge(i12, i8)
+ guard_false(i15) [p1, i14, i10, i12, None, None, None, p3]
+ jump(p3, i12, p1, i14, i10, i7, i8)
+ """
+ opt = self.vectorize(self.parse_loop(trace))
+ assert len(opt.packset.packs) == 2
+ assert len(opt.packset.accum_vars) == 1
+ assert opt.loop.inputargs[4] in opt.packset.accum_vars
+ self.debug_print_operations(opt.loop)
+
def test_element_f45_in_guard_failargs(self):
ops = """
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
@@ -354,6 +354,15 @@
if len_before == len(self.packset.packs):
break
+ if not we_are_translated():
+ # some test cases check the accumulation variables
+ self.packset.accum_vars = {}
+ for pack in self.packset.packs:
+ var = pack.accum_variable
+ pos = pack.accum_position
+ if var:
+ self.packset.accum_vars[var] = pos
+
def schedule(self, vector=False):
self.guard_early_exit = -1
self.clear_newoperations()
@@ -523,15 +532,11 @@
self.operations = operations
self.unroll_count = unroll_count
self.smallest_type_bytes = smallest_type_bytes
- self.accum_vars = {}
def pack_count(self):
return len(self.packs)
def add_pack(self, pack):
- if pack.is_accumulating():
- # remember the variable and the position in this map
- self.accum_vars[pack.accum_variable] = pack.accum_variable
self.packs.append(pack)
def can_be_packed(self, lnode, rnode, origin_pack):
@@ -586,6 +591,9 @@
for op in pack_j.operations[1:]:
operations.append(op)
self.packs[i] = pack = Pack(operations)
+ # preserve the accum variable (if present) of the
+ # left most pack, that is the pack with the earliest
+ # operation at index 0 in the trace
pack.accum_variable = pack_i.accum_variable
pack.accum_position = pack_i.accum_position
@@ -645,7 +653,11 @@
return None, -1
def accumulate_prepare(self, sched_data, renamer):
- for var, pos in self.accum_vars.items():
+ for pack in self.packs:
+ if pack.accum_variable is None:
+ continue
+ var = pack.accum_variable
+ pos = pack.accum_position
# create a new vector box for the parameters
box = vectorbox_outof_box(var)
op = ResOperation(rop.VEC_BOX, [ConstInt(0)], box)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit