Author: Richard Plangger <r...@pasra.at> Branch: vecopt Changeset: r77390:0e3498ee6eb4 Date: 2015-05-19 10:11 +0200 http://bitbucket.org/pypy/pypy/changeset/0e3498ee6eb4/
Log: removed a bug where packtype was modified but not copied before that diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -528,6 +528,15 @@ w_rhs = IntObject(int(w_rhs.floatval)) assert isinstance(w_lhs, W_NDimArray) w_res = w_lhs.descr_getitem(interp.space, w_rhs) + assert isinstance(w_rhs, IntObject) + if isinstance(w_res, boxes.W_Float64Box): + print "access", w_lhs, "[", w_rhs.intval, "] => ", float(w_res.value) + if isinstance(w_res, boxes.W_Float32Box): + print "access", w_lhs, "[", w_rhs.intval, "] => ", float(w_res.value) + if isinstance(w_res, boxes.W_Int64Box): + print "access", w_lhs, "[", w_rhs.intval, "] => ", float(int(w_res.value)) + if isinstance(w_res, boxes.W_Int32Box): + print "access", w_lhs, "[", w_rhs.intval, "] => ", float(int(w_res.value)) else: raise NotImplementedError if (not isinstance(w_res, W_NDimArray) and diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py --- a/pypy/module/micronumpy/test/test_zjit.py +++ b/pypy/module/micronumpy/test/test_zjit.py @@ -154,7 +154,8 @@ return """ a = astype(|30|, int) b = a + 1i - c = a + 2.0 + d = astype(|30|, int) + c = d + 2.0 x1 = b -> 7 x2 = b -> 8 x3 = c -> 11 @@ -164,7 +165,7 @@ def test_int_add_const(self): result = self.run("int_add_const") assert int(result) == 7+1+8+1+11+2+12+2 - self.check_vectorized(1, 1) + self.check_vectorized(2, 2) def define_int32_add_const(): return """ @@ -172,7 +173,9 @@ b = a + 1i x1 = b -> 7 x2 = b -> 8 - x1 + x2 + x3 = b -> 9 + x4 = b -> 10 + x1 + x2 + x3 + x4 """ #return """ #a = astype(|30|, int32) @@ -186,9 +189,27 @@ #""" def test_int32_add_const(self): result = self.run("int32_add_const") - assert int(result) == 7+1+8+1 + assert int(result) == 7+1+8+1+9+1+10+1 self.check_vectorized(1, 1) + def define_int32_copy(): + return """ + a = astype(|30|, float32) + x1 = a -> 7 + x2 = a -> 8 + x3 = a -> 9 + x4 = a -> 10 + x5 = a -> 11 + x6 = a -> 12 + x7 = a -> 13 + x8 = a -> 14 + x9 = a -> 15 + x1 + x2 + x3 + x4 + """ + def test_int32_copy(self): + result = self.run("int32_copy") + assert int(result) == 7+8+9+10 + self.check_vectorized(1, 1) def define_pow(): diff --git a/rpython/jit/backend/x86/assembler.py b/rpython/jit/backend/x86/assembler.py --- a/rpython/jit/backend/x86/assembler.py +++ b/rpython/jit/backend/x86/assembler.py @@ -2564,10 +2564,10 @@ elif size == 8 and tosize == 4: # is there a better sequence to move them? scratch = X86_64_SCRATCH_REG.value - print resloc, "[0] <- int32(", srcloc, "[0])" + #print resloc, "[0] <- int32(", srcloc, "[0])" print resloc, "[1] <- int32(", srcloc, "[1])" - self.mc.PEXTRQ_rxi(scratch, srcloc.value, 0) - self.mc.PINSRD_xri(resloc.value, scratch, 0) + #self.mc.PEXTRQ_rxi(scratch, srcloc.value, 0) + #self.mc.PINSRD_xri(resloc.value, scratch, 0) self.mc.PEXTRQ_rxi(scratch, srcloc.value, 1) self.mc.PINSRD_xri(resloc.value, scratch, 1) else: diff --git a/rpython/jit/backend/x86/regalloc.py b/rpython/jit/backend/x86/regalloc.py --- a/rpython/jit/backend/x86/regalloc.py +++ b/rpython/jit/backend/x86/regalloc.py @@ -1616,7 +1616,7 @@ pass def consider_vec_cast_float_to_singlefloat(self, op): - count = op.getarg(2) + count = op.getarg(1) assert isinstance(count, ConstInt) args = op.getarglist() loc0 = self.make_sure_var_in_reg(op.getarg(0), args) 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 @@ -581,9 +581,10 @@ class OpToVectorOp(object): - def __init__(self, arg_ptypes, result_ptype, index=-1, result_vsize_arg=-1): + def __init__(self, arg_ptypes, result_ptype, has_ptype=False, index=-1, result_vsize_arg=-1): self.arg_ptypes = arg_ptypes self.result_ptype = result_ptype + self.has_ptype = has_ptype # TODO remove them? self.result = result_ptype != None self.result_vsize_arg = result_vsize_arg @@ -620,10 +621,10 @@ rop.VEC_FLOAT_MUL: OpToVectorOp((PT_FLOAT_GENERIC,PT_FLOAT_GENERIC), PT_FLOAT_GENERIC), rop.VEC_FLOAT_EQ: OpToVectorOp((PT_FLOAT_GENERIC,PT_FLOAT_GENERIC), PT_INT_GENERIC), - rop.VEC_RAW_LOAD: OpToVectorOp((), PT_GENERIC), - rop.VEC_GETARRAYITEM_RAW: OpToVectorOp((), PT_GENERIC), - rop.VEC_RAW_STORE: OpToVectorOp((None,None,PT_INT_GENERIC,), None), - rop.VEC_SETARRAYITEM_RAW: OpToVectorOp((None,None,PT_INT_GENERIC,), None), + rop.VEC_RAW_LOAD: OpToVectorOp((), PT_GENERIC, has_ptype=True), + rop.VEC_GETARRAYITEM_RAW: OpToVectorOp((), PT_GENERIC, has_ptype=True), + rop.VEC_RAW_STORE: OpToVectorOp((None,None,PT_GENERIC,), None, has_ptype=True), + rop.VEC_SETARRAYITEM_RAW: OpToVectorOp((None,None,PT_GENERIC,), None, has_ptype=True), rop.VEC_CAST_FLOAT_TO_SINGLEFLOAT: OpToVectorOp((PT_DOUBLE,), PT_FLOAT), # TODO remove index @@ -656,9 +657,6 @@ # properties that hold for the pack are: # + isomorphism (see func above) # + tight packed (no room between vector elems) - if pack.operations[0].op.vector == rop.VEC_RAW_LOAD: - assert pack.ptype is not None - print pack.ptype if pack.ptype is None: self.propagate_ptype() @@ -694,6 +692,8 @@ for i,arg in enumerate(args): arg_ptype = tovector.get_arg_ptype(i) + if arg_ptype and tovector.has_ptype: + arg_ptype = self.pack.ptype if arg_ptype is not None: if arg_ptype.size == -1: arg_ptype = self.pack.ptype @@ -708,8 +708,10 @@ tovector = ROP_ARG_RES_VECTOR.get(op0.vector, None) if tovector is None: raise NotImplementedError("vecop map entry missing. trans: pack -> vop") + if tovector.has_ptype: + assert False, "load/store must have ptypes attached from the descriptor" args = op0.getarglist()[:] - res_ptype = tovector.get_result_ptype() + res_ptype = tovector.get_result_ptype().clone() for i,arg in enumerate(args): if tovector.vector_arg(i): _, vbox = self.box_to_vbox.get(arg, (-1, None)) @@ -722,9 +724,10 @@ def vector_result(self, vop, tovector): ops = self.pack.operations - result = vop.result - ptype = tovector.get_result_ptype() - if ptype is not None and ptype.gettype() != PackType.UNKNOWN_TYPE: + ptype = tovector.get_result_ptype().clone() + if tovector.has_ptype: + ptype = self.pack.ptype + if ptype is not None: if ptype.size == -1: ptype.size = self.pack.ptype.size vbox = self.box_vector(ptype) @@ -771,7 +774,6 @@ return vbox def extend(self, vbox, arg_ptype): - py.test.set_trace() if vbox.item_count * vbox.item_size == self.vec_reg_size: return vbox size = arg_ptype.getsize() @@ -802,7 +804,6 @@ opnum = rop.VEC_FLOAT_PACK if tgt_box.item_type == INT: opnum = rop.VEC_INT_PACK - py.test.set_trace() arg_count = len(args) i = index while i < arg_count and tgt_box.item_count < packable: @@ -813,6 +814,8 @@ continue new_box = tgt_box.clonebox() new_box.item_count += src_box.item_count + if opnum == rop.VEC_FLOAT_PACK: + py.test.set_trace() op = ResOperation(opnum, [tgt_box, src_box, ConstInt(i), ConstInt(src_box.item_count)], new_box) self.preamble_ops.append(op) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit