Author: Richard Plangger <[email protected]>
Branch: vecopt-merge
Changeset: r79641:d3aaa1983ac4
Date: 2015-09-14 20:31 +0200
http://bitbucket.org/pypy/pypy/changeset/d3aaa1983ac4/
Log: work in progress moving vecop creation to OpHelpers
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
@@ -165,17 +165,9 @@
#
raise AssertionError("getunpackopnum type %s not supported" % (type,))
-def getexpandopnum(type):
- if type == INT:
- return rop.VEC_INT_EXPAND
- elif type == FLOAT:
- return rop.VEC_FLOAT_EXPAND
- #
- raise AssertionError("getexpandopnum type %s not supported" % (type,))
-
-UNSIGNED_OPS = (rop.UINT_FLOORDIV, rop.UINT_RSHIFT,
- rop.UINT_LT, rop.UINT_LE,
- rop.UINT_GT, rop.UINT_GE)
+#UNSIGNED_OPS = (rop.UINT_FLOORDIV, rop.UINT_RSHIFT,
+# rop.UINT_LT, rop.UINT_LE,
+# rop.UINT_GT, rop.UINT_GE)
#class Type(object):
# """ The type of one operation. Saves type, size and sign. """
@@ -446,7 +438,7 @@
if not vecop:
# 2) constant/variable expand this box
# TODO just as one function call
- vecop = self.expand(arg, i)
+ vecop = expand(state, pack, args, arg, i)
state.setvector_of_box(arg, 0, vecop)
pos = 0
continue
@@ -696,26 +688,24 @@
assert index.value + count.value <= result.getcount()
assert result.getcount() > arg0.getcount()
-def expand(self, arg, argidx):
+def expand(state, pack, op, arg, argidx):
""" Expand a value into a vector box. useful for arith metic
of one vector with a scalar (either constant/varialbe)
"""
- elem_count = self.input_type.getcount()
- vbox = self.input_type.new_vector_box(elem_count)
+ vecop = OpHelpers.create_vec(OpHelpers.vector_for_type(arg.type), None,
+ arg.type, op.bytesize, op.signed, op.count)
box_type = arg.type
- expanded_map = self.sched_data.expanded_map
- # note that heterogenous nodes are not yet tracked
- already_expanded = expanded_map.get(arg, None)
- if already_expanded:
- return already_expanded
+ #expanded_map = state.expanded_map
+ ## note that heterogenous nodes are not yet tracked
+ #already_expanded = expanded_map.get(arg, None)
+ #if already_expanded:
+ # return already_expanded
- ops = self.sched_data.invariant_oplist
- variables = self.sched_data.invariant_vector_vars
- if isinstance(arg,Box) and arg not in self.sched_data.inputargs:
+ ops = state.invariant_oplist
+ variables = state.invariant_vector_vars
+ if not arg.is_constant() and arg not in state.inputargs:
ops = self.vecops
variables = None
- if isinstance(arg, BoxVector):
- box_type = arg.gettype()
for i, node in enumerate(self.getoperations()):
op = node.getoperation()
@@ -723,12 +713,12 @@
break
i += 1
else:
- expand_opnum = getexpandopnum(box_type)
- op = ResOperation(expand_opnum, [arg, ConstInt(vbox.item_count)], vbox)
+ vecop = OpHelpers.create_expand(arg.type, arg, op.count)
+ ops.append(vecop)
ops.append(op)
if variables is not None:
- variables.append(vbox)
- expanded_map[arg] = vbox
+ variables.append(vecop)
+ expanded_map[arg] = vecop
return vbox
op = ResOperation(rop.VEC_BOX, [ConstInt(elem_count)], vbox)
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
@@ -173,7 +173,7 @@
i10 = int_add(i0, 73)
i11 = int_add(i1, 73)
""")
- pack1 = self.pack(loop1, 0, 2, I64, I64)
+ pack1 = self.pack(loop1, 0, 2)
loop2 = self.schedule(loop1, [pack1], prepend_invariant=True)
loop3 = self.parse_trace("""
v10[2xi64] = vec_box_i()
diff --git a/rpython/jit/metainterp/optimizeopt/vector.py
b/rpython/jit/metainterp/optimizeopt/vector.py
--- a/rpython/jit/metainterp/optimizeopt/vector.py
+++ b/rpython/jit/metainterp/optimizeopt/vector.py
@@ -825,6 +825,7 @@
state.renamer.start_renaming(accum.getoriginalbox(), result)
def split_overloaded_packs(self):
+ import pdb; pdb. set_trace()
newpacks = []
for i,pack in enumerate(self.packs):
load = pack.pack_load(self.vec_reg_size)
diff --git a/rpython/jit/metainterp/resoperation.py
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -4,6 +4,8 @@
from rpython.rlib.objectmodel import compute_identity_hash
from rpython.rtyper.lltypesystem import lltype, llmemory
from rpython.jit.codewriter import longlong
+from rpython.jit.backend.llsupport.symbolic import (WORD as INT_WORD,
+ SIZEOF_FLOAT as FLOAT_WORD)
class SettingForwardedOnAbstractValue(Exception):
pass
@@ -127,13 +129,24 @@
# pass through the type of the first input argument
if self.numargs() == 0:
return
- arg0 = self.getarg(0)
- self.setdatatype(arg0.datatype, arg0.bytesize, arg0.signed)
+ i = 0
+ arg = self.getarg(i)
+ while arg.is_constant() and i+1 < self.numargs():
+ i += 1
+ arg = self.getarg(i)
+ if arg.is_constant():
+ return
+ self.setdatatype(arg.datatype, arg.bytesize, arg.signed)
assert self.datatype != '\x00'
#assert self.bytesize > 0
def setdatatype(self, data_type, bytesize, signed):
self.datatype = data_type
+ if bytesize == -1:
+ if data_type == 'i':
+ bytesize = INT_WORD
+ elif data_type == 'f':
+ bytesize = FLOAT_WORD
self.bytesize = bytesize
self.signed = signed
@@ -994,13 +1007,10 @@
'VEC_CAST_INT_TO_FLOAT/1/f',
'_VEC_CAST_LAST',
- 'VEC_BOX/0/if',
- 'VEC_INT_UNPACK/3/i', # iX|fX = VEC_INT_UNPACK(vX, index,
item_count)
- 'VEC_INT_PACK/4/i', # VEC_INT_PACK(vX, var/const, index,
item_count)
- 'VEC_INT_EXPAND/2/i', # vX = VEC_INT_EXPAND(var/const, item_count)
- 'VEC_FLOAT_UNPACK/3/f', # iX|fX = VEC_FLOAT_UNPACK(vX, index,
item_count)
- 'VEC_FLOAT_PACK/4/f', # VEC_FLOAT_PACK(vX, var/const, index,
item_count)
- 'VEC_FLOAT_EXPAND/2/f', # vX = VEC_FLOAT_EXPAND(var/const,
item_count)
+ 'VEC/0/if',
+ 'VEC_UNPACK/3/if', # iX|fX = VEC_INT_UNPACK(vX, index, item_count)
+ 'VEC_PACK/4/if', # VEC_INT_PACK(vX, var/const, index,
item_count)
+ 'VEC_EXPAND/2/if', # vX = VEC_INT_EXPAND(var/const, item_count)
'_VEC_PURE_LAST',
#
'INT_LT/2b/i',
@@ -1554,3 +1564,22 @@
else:
assert tp == 'f'
return InputArgFloat()
+
+ @staticmethod
+ def create_expand(datatype, arg, bytesize, signed, count):
+ if datatype == 'i':
+ opnum = rop.VEC_EXPAND_I
+ else:
+ assert datatype == 'f'
+ opnum = rop.VEC_EXPAND_F
+ return VecOperationNew(opnum, [arg], datatype, bytesize, signed, count)
+
+ @staticmethod
+ def create_vec(datatype, arg, bytesize, signed, count):
+ if type == 'i':
+ opnum = rop.VEC_I
+ else:
+ assert type == 'f'
+ opnum = rop.VEC_F
+ return VecOperationNew(opnum, [arg], datatype, bytesize, signed, count)
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit