--- old/src/hotspot/cpu/x86/x86.ad 2018-04-04 14:45:46.851207013 -0700 +++ new/src/hotspot/cpu/x86/x86.ad 2018-04-04 14:45:46.595207106 -0700 @@ -2758,9 +2758,8 @@ // ====================VECTOR INSTRUCTIONS===================================== -// FIXME: eliminate VectorReinterpret nodes before matching - instruct reinterpretS(vecS dst) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 4 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); match(Set dst (VectorReinterpret dst)); ins_cost(125); format %{ " # reinterpret $dst" %} @@ -2770,7 +2769,73 @@ ins_pipe( pipe_slow ); %} +instruct reinterpretS2D(vecD dst, vecS src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ pxor($dst$$XMMRegister, $dst$$XMMRegister); + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretS2X(vecX dst, vecS src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ pxor($dst$$XMMRegister, $dst$$XMMRegister); + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretS2Y(vecY dst, vecS src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretS2Z(vecZ dst, vecS src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretD2S(vecS dst, vecD src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 4 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct reinterpretD(vecD dst) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); match(Set dst (VectorReinterpret dst)); ins_cost(125); format %{ " # reinterpret $dst" %} @@ -2780,7 +2845,71 @@ ins_pipe( pipe_slow ); %} +instruct reinterpretD2X(vecX dst, vecD src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ pxor($dst$$XMMRegister, $dst$$XMMRegister); + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretD2Y(vecY dst, vecD src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretD2Z(vecZ dst, vecD src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretX2S(vecS dst, vecX src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 4 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 16); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretX2D(vecD dst, vecX src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 16); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct reinterpretX(vecX dst) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 16); match(Set dst (VectorReinterpret dst)); ins_cost(125); format %{ " # reinterpret $dst" %} @@ -2790,7 +2919,69 @@ ins_pipe( pipe_slow ); %} +instruct reinterpretX2Y(vecY dst, vecX src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 16); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 1; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretX2Z(vecZ dst, vecX src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 16); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretY2S(vecS dst, vecY src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 4 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 32); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretY2D(vecD dst, vecY src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 32); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretY2X(vecX dst, vecY src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 32); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct reinterpretY(vecY dst) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 32); match(Set dst (VectorReinterpret dst)); ins_cost(125); format %{ " # reinterpret $dst" %} @@ -2800,7 +2991,66 @@ ins_pipe( pipe_slow ); %} +instruct reinterpretY2Z(vecZ dst, vecY src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 32); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP dst); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 2; + __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretZ2S(vecS dst, vecZ src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 4 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 64); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretZ2D(vecD dst, vecZ src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 64); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretZ2X(vecX dst, vecZ src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 64); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretZ2Y(vecY dst, vecZ src) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 64); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + instruct reinterpretZ(vecZ dst) %{ + predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 64); match(Set dst (VectorReinterpret dst)); ins_cost(125); format %{ " # reinterpret $dst" %} --- old/src/hotspot/share/classfile/vmSymbols.hpp 2018-04-04 14:45:47.907206626 -0700 +++ new/src/hotspot/share/classfile/vmSymbols.hpp 2018-04-04 14:45:47.647206721 -0700 @@ -1487,11 +1487,11 @@ "Ljdk/incubator/vector/VectorIntrinsics$VectorBroadcastIntOp;)Ljdk/incubator/vector/Vector;") \ do_name(vector_broadcast_int_name, "broadcastInt") \ \ - do_intrinsic(_VectorRebracket, jdk_incubator_vector_VectorIntrinsics, vector_rebracket_name, vector_rebracket_sig, F_S) \ - do_signature(vector_rebracket_sig, "(Ljava/lang/Class;Ljava/lang/Class;I" \ - "Ljava/lang/Class;Ljava/lang/Object;" \ - "Ljdk/incubator/vector/VectorIntrinsics$VectorRebracketOp;)Ljava/lang/Object;") \ - do_name(vector_rebracket_name, "rebracket") \ + do_intrinsic(_VectorReinterpret, jdk_incubator_vector_VectorIntrinsics, vector_reinterpret_name, vector_reinterpret_sig, F_S) \ + do_signature(vector_reinterpret_sig, "(Ljava/lang/Class;Ljava/lang/Class;I" \ + "Ljava/lang/Class;ILjava/lang/Object;" \ + "Ljdk/incubator/vector/VectorIntrinsics$VectorReinterpretOp;)Ljava/lang/Object;") \ + do_name(vector_reinterpret_name, "reinterpret") \ \ do_intrinsic(_VectorRebox, jdk_incubator_vector_VectorIntrinsics, vector_rebox_name, vector_rebox_sig, F_S) \ do_alias(vector_rebox_sig, object_object_signature) \ @@ -1683,7 +1683,7 @@ #undef VM_INTRINSIC_ENUM ID_LIMIT, - LAST_COMPILER_INLINE = _VectorRebracket, + LAST_COMPILER_INLINE = _VectorReinterpret, FIRST_VECTOR_API = _VectorUnaryOp, LAST_VECTOR_API = _VectorRebox, FIRST_MH_SIG_POLY = _invokeGeneric, --- old/src/hotspot/share/opto/library_call.cpp 2018-04-04 14:45:48.883206270 -0700 +++ new/src/hotspot/share/opto/library_call.cpp 2018-04-04 14:45:48.623206365 -0700 @@ -339,10 +339,11 @@ bool inline_vector_blend(); bool inline_vector_compare(); bool inline_vector_broadcast_int(); - bool inline_vector_rebracket(); + bool inline_vector_reinterpret(); Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType bt, int num_elem); Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType bt, int num_elem); Node* shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem); + void set_vector_result(Node* result, bool set_res = true); void clear_upper_avx() { #ifdef X86 @@ -907,8 +908,8 @@ return inline_vector_compare(); case vmIntrinsics::_VectorBroadcastInt: return inline_vector_broadcast_int(); - case vmIntrinsics::_VectorRebracket: - return inline_vector_rebracket(); + case vmIntrinsics::_VectorReinterpret: + return inline_vector_reinterpret(); default: // If you get here, it may be that someone has added a new intrinsic @@ -7187,6 +7188,19 @@ return unbox; } +void LibraryCallKit::set_vector_result(Node* result, bool set_res) { + if (DebugVectorApi) { + tty->print("============ "); + callee()->print(); + tty->print_cr(" ============"); + result->dump(5); + tty->print_cr("----------------------------------------------------"); + } + if (set_res) { + set_result(result); + } +} + bool LibraryCallKit::inline_vector_nary_operation(int n) { const TypeInt* opr = gvn().type(argument(0))->is_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->is_instptr(); @@ -7253,7 +7267,7 @@ } // Wrap it up in VectorBox to keep object type information. operation = box_vector(operation, vbox_type, elem_bt, num_elem); - set_result(operation); + set_vector_result(operation); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; @@ -7318,7 +7332,7 @@ Node* broadcast = VectorNode::scalar2vector(elem, num_elem, Type::get_const_basic_type(elem_bt)); broadcast = gvn().transform(broadcast); Node* box = box_vector(broadcast, vbox_type, elem_bt, num_elem); - set_result(box); + set_vector_result(box); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; @@ -7379,10 +7393,11 @@ set_all_memory(reset_memory()); Node* vstore = gvn().transform(StoreVectorNode::make(0, control(), memory(adr), adr, adr_type, val, num_elem)); set_memory(vstore, adr_type); + set_vector_result(vstore, false); } else { Node* vload = gvn().transform(LoadVectorNode::make(0, control(), memory(adr), adr, adr_type, num_elem, elem_bt)); Node* box = box_vector(vload, vbox_type, elem_bt, num_elem); - set_result(box); + set_vector_result(box); } C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); @@ -7450,7 +7465,7 @@ } default: fatal("%s", type2name(elem_bt)); } - set_result(bits); + set_vector_result(bits); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; } @@ -7489,7 +7504,7 @@ } Node* test = new VectorTestNode(opd1, opd2, booltest); test = _gvn.transform(test); - set_result(test); + set_vector_result(test); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; } @@ -7537,7 +7552,7 @@ Node* blend = _gvn.transform(new VectorBlendNode(v1, v2, mask)); Node* box = box_vector(blend, vbox_type, elem_bt, num_elem); - set_result(box); + set_vector_result(box); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; @@ -7591,7 +7606,7 @@ Node* operation = _gvn.transform(new VectorMaskCmpNode(pred, v1, v2, vt)); Node* box = box_vector(operation, mbox_type, mask_bt, num_elem); - set_result(box); + set_vector_result(box); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; @@ -7655,7 +7670,7 @@ Node* operation = _gvn.transform(VectorNode::make(sopc, opd1, opd2, num_elem, elem_bt)); Node* vbox = box_vector(operation, vbox_type, elem_bt, num_elem); - set_result(vbox); + set_vector_result(vbox); C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt)))); return true; } @@ -7677,15 +7692,16 @@ return T_ILLEGAL; } -bool LibraryCallKit::inline_vector_rebracket() { +bool LibraryCallKit::inline_vector_reinterpret() { const TypeInstPtr* vector_klass_from = gvn().type(argument(0))->is_instptr(); const TypeInstPtr* elem_klass_from = gvn().type(argument(1))->is_instptr(); const TypeInt* vlen_from = gvn().type(argument(2))->is_int(); const TypeInstPtr* elem_klass_to = gvn().type(argument(3))->is_instptr(); + const TypeInt* vlen_to = gvn().type(argument(4))->is_int(); if (vector_klass_from->const_oop() == NULL || elem_klass_from->const_oop() == NULL || !vlen_from->is_con() || - elem_klass_to->const_oop() == NULL ) { + elem_klass_to->const_oop() == NULL || !vlen_to->is_con()) { return false; // not enough info for intrinsification } @@ -7715,18 +7731,30 @@ return false; // type mismatch } int num_elem_from = vlen_from->get_con(); + int num_elem_to = vlen_to->get_con(); + if (is_mask) { + elem_bt_to = getMaskBasicType(elem_bt_to); + } - int num_elem_to = (type2aelembytes(elem_bt_from) * num_elem_from) / type2aelembytes(elem_bt_to); - if (num_elem_to == 0) { + // Check whether we can unbox to appropriate size. + if (!arch_supports_vector(Op_VectorReinterpret, + num_elem_from, + elem_bt_from, + is_mask ? VecMaskUseAll : VecMaskNotUsed)) { return false; } - if (is_mask) { - elem_bt_to = getMaskBasicType(elem_bt_to); + + // Check whether we can support resizing/reinterpreting to the new size. + if (!arch_supports_vector(Op_VectorReinterpret, + num_elem_to, + elem_bt_to, + is_mask ? VecMaskUseAll : VecMaskNotUsed)) { + return false; } const TypeInstPtr* vbox_type_from = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass_from); - Node* opd1 = unbox_vector(argument(4), vbox_type_from, elem_bt_from, num_elem_from); + Node* opd1 = unbox_vector(argument(5), vbox_type_from, elem_bt_from, num_elem_from); if (opd1 == NULL) { return false; } @@ -7744,7 +7772,7 @@ num_elem_to, is_mask ? VECAPI_MASK : VECAPI_VECTOR); const TypeInstPtr* vbox_type_to = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass_to); Node* vbox = box_vector(op, vbox_type_to, elem_bt_to, num_elem_to); - set_result(vbox); + set_vector_result(vbox); return true; } --- old/src/hotspot/share/opto/vectornode.hpp 2018-04-04 14:45:49.899205900 -0700 +++ new/src/hotspot/share/opto/vectornode.hpp 2018-04-04 14:45:49.647205992 -0700 @@ -1067,16 +1067,7 @@ class VectorReinterpretNode : public VectorNode { public: VectorReinterpretNode(Node* in, const TypeVect* src_vt, const TypeVect* dst_vt) - : VectorNode(in, dst_vt) { - BasicType src_bt = src_vt->element_basic_type(); - BasicType dst_bt = dst_vt->element_basic_type(); - int src_len = src_vt->length(); - int dst_len = dst_vt->length(); - // For now require consistency in resulting vector size. Otherwise we will need - // some backend tricks to handle register allocation for size change. - assert(type2aelembytes(src_bt) * src_len == type2aelembytes(dst_bt) * dst_len, - "reinterpreting means we cannot change vector size upwards"); - } + : VectorNode(in, dst_vt) { } virtual int Opcode() const; }; --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java 2018-04-04 14:45:50.879205541 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java 2018-04-04 14:45:50.623205633 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte128Vector.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte128Mask.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Byte.class; } @Override + @ForceInline public int elementSize() { return Byte.SIZE; } @Override + @ForceInline public Shapes.S128Bit shape() { return Shapes.S_128_BIT; } @@ -978,5 +983,43 @@ public Byte128Vector fromArray(byte[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte128Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.reinterpret( + Byte64Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.reinterpret( + Byte128Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.reinterpret( + Byte256Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.reinterpret( + Byte512Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java 2018-04-04 14:45:51.851205185 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java 2018-04-04 14:45:51.595205280 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte256Vector.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte256Mask.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Byte.class; } @Override + @ForceInline public int elementSize() { return Byte.SIZE; } @Override + @ForceInline public Shapes.S256Bit shape() { return Shapes.S_256_BIT; } @@ -978,5 +983,43 @@ public Byte256Vector fromArray(byte[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte256Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.reinterpret( + Byte64Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.reinterpret( + Byte128Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.reinterpret( + Byte256Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.reinterpret( + Byte512Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java 2018-04-04 14:45:52.819204831 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java 2018-04-04 14:45:52.563204925 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte512Vector.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte512Mask.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Byte.class; } @Override + @ForceInline public int elementSize() { return Byte.SIZE; } @Override + @ForceInline public Shapes.S512Bit shape() { return Shapes.S_512_BIT; } @@ -978,5 +983,43 @@ public Byte512Vector fromArray(byte[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte512Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.reinterpret( + Byte64Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.reinterpret( + Byte128Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.reinterpret( + Byte256Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.reinterpret( + Byte512Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java 2018-04-04 14:45:53.791204477 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java 2018-04-04 14:45:53.535204569 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte64Vector.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Byte64Mask.class, byte.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Byte.class; } @Override + @ForceInline public int elementSize() { return Byte.SIZE; } @Override + @ForceInline public Shapes.S64Bit shape() { return Shapes.S_64_BIT; } @@ -978,5 +983,43 @@ public Byte64Vector fromArray(byte[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte64Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.reinterpret( + Byte64Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.reinterpret( + Byte128Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.reinterpret( + Byte256Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.reinterpret( + Byte512Vector.class, byte.class, so.length(), + Byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java 2018-04-04 14:45:54.763204122 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java 2018-04-04 14:45:54.507204214 -0700 @@ -251,7 +251,7 @@ @Override @ForceInline public ByteVector resize(Species species) { - return (ByteVector) species.reshape(this); + return (ByteVector) species.resize(this); } @Override --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java 2018-04-04 14:45:55.731203766 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java 2018-04-04 14:45:55.475203861 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double128Vector.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double128Mask.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Double.class; } @Override + @ForceInline public int elementSize() { return Double.SIZE; } @Override + @ForceInline public Shapes.S128Bit shape() { return Shapes.S_128_BIT; } @@ -1024,5 +1029,43 @@ public Double128Vector fromArray(double[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double128Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.reinterpret( + Double64Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double128Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.reinterpret( + Double128Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double128Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.reinterpret( + Double256Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double128Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.reinterpret( + Double512Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double128Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java 2018-04-04 14:45:56.695203414 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java 2018-04-04 14:45:56.439203509 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double256Vector.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double256Mask.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Double.class; } @Override + @ForceInline public int elementSize() { return Double.SIZE; } @Override + @ForceInline public Shapes.S256Bit shape() { return Shapes.S_256_BIT; } @@ -1024,5 +1029,43 @@ public Double256Vector fromArray(double[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double256Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.reinterpret( + Double64Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double256Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.reinterpret( + Double128Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double256Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.reinterpret( + Double256Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double256Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.reinterpret( + Double512Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double256Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java 2018-04-04 14:45:57.667203059 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java 2018-04-04 14:45:57.411203153 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double512Vector.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double512Mask.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Double.class; } @Override + @ForceInline public int elementSize() { return Double.SIZE; } @Override + @ForceInline public Shapes.S512Bit shape() { return Shapes.S_512_BIT; } @@ -1024,5 +1029,43 @@ public Double512Vector fromArray(double[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double512Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.reinterpret( + Double64Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double512Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.reinterpret( + Double128Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double512Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.reinterpret( + Double256Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double512Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.reinterpret( + Double512Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double512Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java 2018-04-04 14:45:58.639202705 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java 2018-04-04 14:45:58.383202797 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double64Vector.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Double64Mask.class, double.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Double.class; } @Override + @ForceInline public int elementSize() { return Double.SIZE; } @Override + @ForceInline public Shapes.S64Bit shape() { return Shapes.S_64_BIT; } @@ -1024,5 +1029,43 @@ public Double64Vector fromArray(double[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double64Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.reinterpret( + Double64Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double64Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.reinterpret( + Double128Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double64Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.reinterpret( + Double256Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double64Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.reinterpret( + Double512Vector.class, double.class, so.length(), + Double.class, LENGTH, so, + (v, t) -> (Double64Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java 2018-04-04 14:45:59.607202350 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java 2018-04-04 14:45:59.351202445 -0700 @@ -252,7 +252,7 @@ @Override @ForceInline public DoubleVector resize(Species species) { - return (DoubleVector) species.reshape(this); + return (DoubleVector) species.resize(this); } @Override --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java 2018-04-04 14:46:00.579201995 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java 2018-04-04 14:46:00.319202090 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float128Vector.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float128Mask.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Float.class; } @Override + @ForceInline public int elementSize() { return Float.SIZE; } @Override + @ForceInline public Shapes.S128Bit shape() { return Shapes.S_128_BIT; } @@ -1024,5 +1029,43 @@ public Float128Vector fromArray(float[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float128Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.reinterpret( + Float64Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float128Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.reinterpret( + Float128Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float128Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.reinterpret( + Float256Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float128Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.reinterpret( + Float512Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float128Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java 2018-04-04 14:46:01.551201639 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java 2018-04-04 14:46:01.295201733 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float256Vector.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float256Mask.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Float.class; } @Override + @ForceInline public int elementSize() { return Float.SIZE; } @Override + @ForceInline public Shapes.S256Bit shape() { return Shapes.S_256_BIT; } @@ -1024,5 +1029,43 @@ public Float256Vector fromArray(float[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float256Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.reinterpret( + Float64Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float256Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.reinterpret( + Float128Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float256Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.reinterpret( + Float256Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float256Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.reinterpret( + Float512Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float256Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java 2018-04-04 14:46:02.523201286 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java 2018-04-04 14:46:02.267201378 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float512Vector.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float512Mask.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Float.class; } @Override + @ForceInline public int elementSize() { return Float.SIZE; } @Override + @ForceInline public Shapes.S512Bit shape() { return Shapes.S_512_BIT; } @@ -1024,5 +1029,43 @@ public Float512Vector fromArray(float[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float512Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.reinterpret( + Float64Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float512Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.reinterpret( + Float128Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float512Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.reinterpret( + Float256Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float512Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.reinterpret( + Float512Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float512Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java 2018-04-04 14:46:03.487200933 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java 2018-04-04 14:46:03.235201025 -0700 @@ -719,9 +719,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float64Vector.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -810,9 +810,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Float64Mask.class, float.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -909,26 +909,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Float.class; } @Override + @ForceInline public int elementSize() { return Float.SIZE; } @Override + @ForceInline public Shapes.S64Bit shape() { return Shapes.S_64_BIT; } @@ -1024,5 +1029,43 @@ public Float64Vector fromArray(float[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float64Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.reinterpret( + Float64Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float64Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.reinterpret( + Float128Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float64Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.reinterpret( + Float256Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float64Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.reinterpret( + Float512Vector.class, float.class, so.length(), + Float.class, LENGTH, so, + (v, t) -> (Float64Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java 2018-04-04 14:46:04.463200575 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java 2018-04-04 14:46:04.207200670 -0700 @@ -252,7 +252,7 @@ @Override @ForceInline public FloatVector resize(Species species) { - return (FloatVector) species.reshape(this); + return (FloatVector) species.resize(this); } @Override --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java 2018-04-04 14:46:05.431200223 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java 2018-04-04 14:46:05.175200315 -0700 @@ -744,9 +744,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int128Vector.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -835,9 +835,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int128Mask.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -934,26 +934,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Integer.class; } @Override + @ForceInline public int elementSize() { return Integer.SIZE; } @Override + @ForceInline public Shapes.S128Bit shape() { return Shapes.S_128_BIT; } @@ -1049,5 +1054,43 @@ public Int128Vector fromArray(int[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int128Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.reinterpret( + Int64Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int128Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.reinterpret( + Int128Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int128Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.reinterpret( + Int256Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int128Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.reinterpret( + Int512Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int128Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java 2018-04-04 14:46:06.403199866 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java 2018-04-04 14:46:06.147199959 -0700 @@ -744,9 +744,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int256Vector.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -835,9 +835,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int256Mask.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -934,26 +934,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Integer.class; } @Override + @ForceInline public int elementSize() { return Integer.SIZE; } @Override + @ForceInline public Shapes.S256Bit shape() { return Shapes.S_256_BIT; } @@ -1049,5 +1054,43 @@ public Int256Vector fromArray(int[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int256Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.reinterpret( + Int64Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int256Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.reinterpret( + Int128Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int256Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.reinterpret( + Int256Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int256Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.reinterpret( + Int512Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int256Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java 2018-04-04 14:46:07.375199511 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java 2018-04-04 14:46:07.119199606 -0700 @@ -744,9 +744,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int512Vector.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -835,9 +835,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int512Mask.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -934,26 +934,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Integer.class; } @Override + @ForceInline public int elementSize() { return Integer.SIZE; } @Override + @ForceInline public Shapes.S512Bit shape() { return Shapes.S_512_BIT; } @@ -1049,5 +1054,43 @@ public Int512Vector fromArray(int[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int512Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.reinterpret( + Int64Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int512Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.reinterpret( + Int128Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int512Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.reinterpret( + Int256Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int512Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.reinterpret( + Int512Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int512Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java 2018-04-04 14:46:08.339199159 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java 2018-04-04 14:46:08.087199251 -0700 @@ -744,9 +744,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int64Vector.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -835,9 +835,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Int64Mask.class, int.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -934,26 +934,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Integer.class; } @Override + @ForceInline public int elementSize() { return Integer.SIZE; } @Override + @ForceInline public Shapes.S64Bit shape() { return Shapes.S_64_BIT; } @@ -1049,5 +1054,43 @@ public Int64Vector fromArray(int[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int64Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.reinterpret( + Int64Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int64Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.reinterpret( + Int128Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int64Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.reinterpret( + Int256Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int64Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.reinterpret( + Int512Vector.class, int.class, so.length(), + Integer.class, LENGTH, so, + (v, t) -> (Int64Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java 2018-04-04 14:46:09.307198806 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java 2018-04-04 14:46:09.051198898 -0700 @@ -252,7 +252,7 @@ @Override @ForceInline public IntVector resize(Species species) { - return (IntVector) species.reshape(this); + return (IntVector) species.resize(this); } @Override --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java 2018-04-04 14:46:10.275198451 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java 2018-04-04 14:46:10.019198546 -0700 @@ -707,9 +707,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long128Vector.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -798,9 +798,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long128Mask.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -897,26 +897,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Long.class; } @Override + @ForceInline public int elementSize() { return Long.SIZE; } @Override + @ForceInline public Shapes.S128Bit shape() { return Shapes.S_128_BIT; } @@ -1012,5 +1017,43 @@ public Long128Vector fromArray(long[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long128Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.reinterpret( + Long64Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long128Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.reinterpret( + Long128Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long128Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.reinterpret( + Long256Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long128Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.reinterpret( + Long512Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long128Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java 2018-04-04 14:46:11.243198099 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java 2018-04-04 14:46:10.987198191 -0700 @@ -707,9 +707,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long256Vector.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -798,9 +798,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long256Mask.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -897,26 +897,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Long.class; } @Override + @ForceInline public int elementSize() { return Long.SIZE; } @Override + @ForceInline public Shapes.S256Bit shape() { return Shapes.S_256_BIT; } @@ -1012,5 +1017,43 @@ public Long256Vector fromArray(long[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long256Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.reinterpret( + Long64Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long256Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.reinterpret( + Long128Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long256Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.reinterpret( + Long256Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long256Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.reinterpret( + Long512Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long256Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java 2018-04-04 14:46:12.211197743 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java 2018-04-04 14:46:11.955197838 -0700 @@ -707,9 +707,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long512Vector.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -798,9 +798,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long512Mask.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -897,26 +897,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Long.class; } @Override + @ForceInline public int elementSize() { return Long.SIZE; } @Override + @ForceInline public Shapes.S512Bit shape() { return Shapes.S_512_BIT; } @@ -1012,5 +1017,43 @@ public Long512Vector fromArray(long[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long512Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.reinterpret( + Long64Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long512Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.reinterpret( + Long128Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long512Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.reinterpret( + Long256Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long512Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.reinterpret( + Long512Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long512Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java 2018-04-04 14:46:13.179197391 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java 2018-04-04 14:46:12.919197486 -0700 @@ -707,9 +707,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long64Vector.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -798,9 +798,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Long64Mask.class, long.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -897,26 +897,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Long.class; } @Override + @ForceInline public int elementSize() { return Long.SIZE; } @Override + @ForceInline public Shapes.S64Bit shape() { return Shapes.S_64_BIT; } @@ -1012,5 +1017,43 @@ public Long64Vector fromArray(long[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long64Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.reinterpret( + Long64Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long64Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.reinterpret( + Long128Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long64Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.reinterpret( + Long256Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long64Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.reinterpret( + Long512Vector.class, long.class, so.length(), + Long.class, LENGTH, so, + (v, t) -> (Long64Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java 2018-04-04 14:46:14.147197036 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java 2018-04-04 14:46:13.891197131 -0700 @@ -252,7 +252,7 @@ @Override @ForceInline public LongVector resize(Species species) { - return (LongVector) species.reshape(this); + return (LongVector) species.resize(this); } @Override --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java 2018-04-04 14:46:15.111196683 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java 2018-04-04 14:46:14.855196778 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short128Vector.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short128Mask.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Short.class; } @Override + @ForceInline public int elementSize() { return Short.SIZE; } @Override + @ForceInline public Shapes.S128Bit shape() { return Shapes.S_128_BIT; } @@ -978,5 +983,43 @@ public Short128Vector fromArray(short[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short128Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.reinterpret( + Short64Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short128Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.reinterpret( + Short128Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short128Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.reinterpret( + Short256Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short128Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.reinterpret( + Short512Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short128Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java 2018-04-04 14:46:16.079196331 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java 2018-04-04 14:46:15.823196423 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short256Vector.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short256Mask.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Short.class; } @Override + @ForceInline public int elementSize() { return Short.SIZE; } @Override + @ForceInline public Shapes.S256Bit shape() { return Shapes.S_256_BIT; } @@ -978,5 +983,43 @@ public Short256Vector fromArray(short[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short256Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.reinterpret( + Short64Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short256Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.reinterpret( + Short128Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short256Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.reinterpret( + Short256Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short256Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.reinterpret( + Short512Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short256Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java 2018-04-04 14:46:17.043195979 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java 2018-04-04 14:46:16.791196070 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short512Vector.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short512Mask.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Short.class; } @Override + @ForceInline public int elementSize() { return Short.SIZE; } @Override + @ForceInline public Shapes.S512Bit shape() { return Shapes.S_512_BIT; } @@ -978,5 +983,43 @@ public Short512Vector fromArray(short[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short512Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.reinterpret( + Short64Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short512Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.reinterpret( + Short128Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short512Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.reinterpret( + Short256Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short512Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.reinterpret( + Short512Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short512Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java 2018-04-04 14:46:18.011195623 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java 2018-04-04 14:46:17.755195717 -0700 @@ -673,9 +673,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short64Vector.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -764,9 +764,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( Short64Mask.class, short.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -863,26 +863,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class elementType() { return Short.class; } @Override + @ForceInline public int elementSize() { return Short.SIZE; } @Override + @ForceInline public Shapes.S64Bit shape() { return Shapes.S_64_BIT; } @@ -978,5 +983,43 @@ public Short64Vector fromArray(short[] a, int ax, Mask m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short64Vector resize(Vector o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.reinterpret( + Short64Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short64Vector)reshape(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.reinterpret( + Short128Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short64Vector)reshape(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.reinterpret( + Short256Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short64Vector)reshape(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.reinterpret( + Short512Vector.class, short.class, so.length(), + Short.class, LENGTH, so, + (v, t) -> (Short64Vector)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java 2018-04-04 14:46:18.975195271 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java 2018-04-04 14:46:18.719195365 -0700 @@ -252,7 +252,7 @@ @Override @ForceInline public ShortVector resize(Species species) { - return (ShortVector) species.reshape(this); + return (ShortVector) species.resize(this); } @Override --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java 2018-04-04 14:46:19.943194918 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java 2018-04-04 14:46:19.687195011 -0700 @@ -207,16 +207,16 @@ /* ============================================================================ */ - interface VectorRebracketOp { + interface VectorReinterpretOp { VT apply(VF v, Class elementType); } @HotSpotIntrinsicCandidate static - VT rebracket(Class fromVectorClass, Class fromElementType, int fromVLen, - Class toElementType, VF v, - VectorRebracketOp defaultImpl) { + VT reinterpret(Class fromVectorClass, Class fromElementType, int fromVLen, + Class toElementType, int toVLen, VF v, + VectorReinterpretOp defaultImpl) { return defaultImpl.apply(v, toElementType); } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template 2018-04-04 14:46:20.907194566 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template 2018-04-04 14:46:20.655194657 -0700 @@ -254,7 +254,7 @@ @Override @ForceInline public $abstractvectortype$ resize(Species<$Boxtype$, T> species) { - return ($abstractvectortype$) species.reshape(this); + return ($abstractvectortype$) species.resize(this); } @Override @@ -789,6 +789,7 @@ } @Override + @ForceInline public $abstractvectortype$ reshape(Vector o) { int blen = Math.max(o.species().bitSize(), bitSize()) / Byte.SIZE; ByteBuffer bb = ByteBuffer.allocate(blen).order(ByteOrder.nativeOrder()); --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template 2018-04-04 14:46:21.879194210 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template 2018-04-04 14:46:21.623194305 -0700 @@ -899,9 +899,9 @@ // TODO: check proper element type // TODO: update to pass the two species as an arguments and ideally // push down intrinsic call into species implementation - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( $vectortype$.class, $type$.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (v, t) -> species.reshape(v) ); } @@ -990,9 +990,9 @@ public Mask rebracket(Species species) { Objects.requireNonNull(species); // TODO: check proper element type - return VectorIntrinsics.rebracket( + return VectorIntrinsics.reinterpret( $masktype$.class, $type$.class, LENGTH, - species.elementType(), this, + species.elementType(), species.length(), this, (m, t) -> m.reshape(species) ); } @@ -1089,26 +1089,31 @@ } @Override + @ForceInline public int bitSize() { return BIT_SIZE; } @Override + @ForceInline public int length() { return LENGTH; } @Override + @ForceInline public Class<$Boxtype$> elementType() { return $Boxtype$.class; } @Override + @ForceInline public int elementSize() { return $Boxtype$.SIZE; } @Override + @ForceInline public Shapes.$shape$ shape() { return Shapes.$Shape$; } @@ -1224,5 +1229,43 @@ public $vectortype$ fromArray($type$[] a, int ax, Mask<$Boxtype$, Shapes.$shape$> m) { return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public $vectortype$ resize(Vector<$Boxtype$, T> o) { + Objects.requireNonNull(o); + if (o.bitSize() == 64) { + $Type$64Vector so = ($Type$64Vector)o; + return VectorIntrinsics.reinterpret( + $Type$64Vector.class, $type$.class, so.length(), + $Boxtype$.class, LENGTH, so, + (v, t) -> ($vectortype$)reshape(v) + ); + } else if (o.bitSize() == 128) { + $Type$128Vector so = ($Type$128Vector)o; + return VectorIntrinsics.reinterpret( + $Type$128Vector.class, $type$.class, so.length(), + $Boxtype$.class, LENGTH, so, + (v, t) -> ($vectortype$)reshape(v) + ); + } else if (o.bitSize() == 256) { + $Type$256Vector so = ($Type$256Vector)o; + return VectorIntrinsics.reinterpret( + $Type$256Vector.class, $type$.class, so.length(), + $Boxtype$.class, LENGTH, so, + (v, t) -> ($vectortype$)reshape(v) + ); + } else if (o.bitSize() == 512) { + $Type$512Vector so = ($Type$512Vector)o; + return VectorIntrinsics.reinterpret( + $Type$512Vector.class, $type$.class, so.length(), + $Boxtype$.class, LENGTH, so, + (v, t) -> ($vectortype$)reshape(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } } } --- /dev/null 2018-03-29 08:59:35.739332458 -0700 +++ new/test/jdk/jdk/incubator/vector/VectorReshapeTests.java 2018-04-04 14:46:22.599193947 -0700 @@ -0,0 +1,265 @@ +import jdk.incubator.vector.*; +import jdk.internal.vm.annotation.ForceInline; +import org.testng.Assert; +import org.testng.annotations.Test; +import org.testng.annotations.DataProvider; + +import java.util.List; +import java.util.function.IntFunction; + +/** + * @test + * @modules jdk.incubator.vector + * @modules java.base/jdk.internal.vm.annotation + * @run testng VectorReshapeTests + */ + +@Test +public class VectorReshapeTests { + static final int NUM_ITER = 20; + + static final IntVector.IntSpecies ispec64 = (IntVector.IntSpecies) Vector.speciesInstance(Integer.class, Shapes.S_64_BIT); + static final FloatVector.FloatSpecies fspec64 = (FloatVector.FloatSpecies) Vector.speciesInstance(Float.class, Shapes.S_64_BIT); + static final LongVector.LongSpecies lspec64 = (LongVector.LongSpecies) Vector.speciesInstance(Long.class, Shapes.S_64_BIT); + static final DoubleVector.DoubleSpecies dspec64 = (DoubleVector.DoubleSpecies) Vector.speciesInstance(Double.class, Shapes.S_64_BIT); + static final ByteVector.ByteSpecies bspec64 = (ByteVector.ByteSpecies) Vector.speciesInstance(Byte.class, Shapes.S_64_BIT); + static final ShortVector.ShortSpecies sspec64 = (ShortVector.ShortSpecies) Vector.speciesInstance(Short.class, Shapes.S_64_BIT); + + static final IntVector.IntSpecies ispec128 = (IntVector.IntSpecies) Vector.speciesInstance(Integer.class, Shapes.S_128_BIT); + static final FloatVector.FloatSpecies fspec128 = (FloatVector.FloatSpecies) Vector.speciesInstance(Float.class, Shapes.S_128_BIT); + static final LongVector.LongSpecies lspec128 = (LongVector.LongSpecies) Vector.speciesInstance(Long.class, Shapes.S_128_BIT); + static final DoubleVector.DoubleSpecies dspec128 = (DoubleVector.DoubleSpecies) Vector.speciesInstance(Double.class, Shapes.S_128_BIT); + static final ByteVector.ByteSpecies bspec128 = (ByteVector.ByteSpecies) Vector.speciesInstance(Byte.class, Shapes.S_128_BIT); + static final ShortVector.ShortSpecies sspec128 = (ShortVector.ShortSpecies) Vector.speciesInstance(Short.class, Shapes.S_128_BIT); + + static final IntVector.IntSpecies ispec256 = (IntVector.IntSpecies) Vector.speciesInstance(Integer.class, Shapes.S_256_BIT); + static final FloatVector.FloatSpecies fspec256 = (FloatVector.FloatSpecies) Vector.speciesInstance(Float.class, Shapes.S_256_BIT); + static final LongVector.LongSpecies lspec256 = (LongVector.LongSpecies) Vector.speciesInstance(Long.class, Shapes.S_256_BIT); + static final DoubleVector.DoubleSpecies dspec256 = (DoubleVector.DoubleSpecies) Vector.speciesInstance(Double.class, Shapes.S_256_BIT); + static final ByteVector.ByteSpecies bspec256 = (ByteVector.ByteSpecies) Vector.speciesInstance(Byte.class, Shapes.S_256_BIT); + static final ShortVector.ShortSpecies sspec256 = (ShortVector.ShortSpecies) Vector.speciesInstance(Short.class, Shapes.S_256_BIT); + + static final IntVector.IntSpecies ispec512 = (IntVector.IntSpecies) Vector.speciesInstance(Integer.class, Shapes.S_512_BIT); + static final FloatVector.FloatSpecies fspec512 = (FloatVector.FloatSpecies) Vector.speciesInstance(Float.class, Shapes.S_512_BIT); + static final LongVector.LongSpecies lspec512 = (LongVector.LongSpecies) Vector.speciesInstance(Long.class, Shapes.S_512_BIT); + static final DoubleVector.DoubleSpecies dspec512 = (DoubleVector.DoubleSpecies) Vector.speciesInstance(Double.class, Shapes.S_512_BIT); + static final ByteVector.ByteSpecies bspec512 = (ByteVector.ByteSpecies) Vector.speciesInstance(Byte.class, Shapes.S_512_BIT); + static final ShortVector.ShortSpecies sspec512 = (ShortVector.ShortSpecies) Vector.speciesInstance(Short.class, Shapes.S_512_BIT); + + static IntFunction withToString(String s, IntFunction f) { + return new IntFunction() { + @Override + public T apply(int v) { + return f.apply(v); + } + + @Override + public String toString() { + return s; + } + }; + } + + interface ToByteF { + byte apply(int i); + } + + static byte[] fill(int s , ToByteF f) { + return fill(new byte[s], f); + } + + static byte[] fill(byte[] a, ToByteF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static final List> BYTE_GENERATORS = List.of( + withToString("byte[i * 5]", (int s) -> { + return fill(s * 1000, + i -> (byte)(i * 5)); + }), + withToString("byte[i + 1]", (int s) -> { + return fill(s * 1000, + i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1))); + }) + ); + + @DataProvider + public Object[][] byteUnaryOpProvider() { + return BYTE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @ForceInline + static void testResize(Vector.Species a, Vector.Species b, byte[] input) { + int spec_a_num_bytes = a.bitSize() / Byte.SIZE; + int spec_b_num_bytes = b.bitSize() / Byte.SIZE; + + // Set a loop bound so that a load will not go out of bounds based on vector size. + int loop_bound = Math.min(input.length - spec_a_num_bytes, input.length - spec_b_num_bytes); + + // Create arrays being used for storing. Use largest size. + int max_num_bytes = Math.max(spec_a_num_bytes, spec_b_num_bytes); + int min_num_bytes = Math.min(spec_a_num_bytes, spec_b_num_bytes); + byte[] actual = new byte[max_num_bytes]; + byte[] expected = new byte[max_num_bytes]; + + for (int i = 0; i < loop_bound; i++) { + Vector av = a.fromByteArray(input, i); + Vector bv = av.resize(b); + bv.intoByteArray(actual, 0); + + // Compute expected. + for (int j = 0; j < max_num_bytes; j++) { + if (j < min_num_bytes) { + expected[j] = input[i+j]; + } else { + expected[j] = 0; + } + } + + Assert.assertEquals(expected, actual); + } + } + + @Test(dataProvider = "byteUnaryOpProvider", invocationCount = 2) + static void testResizeByte(IntFunction fa) { + byte[] barr = fa.apply(bspec64.elementSize()); + for (int i = 0; i < NUM_ITER; i++) { + testResize(bspec64, bspec64, barr); + testResize(bspec64, bspec128, barr); + testResize(bspec64, bspec256, barr); + testResize(bspec64, bspec512, barr); + testResize(bspec128, bspec64, barr); + testResize(bspec128, bspec128, barr); + testResize(bspec128, bspec256, barr); + testResize(bspec128, bspec512, barr); + testResize(bspec256, bspec64, barr); + testResize(bspec256, bspec128, barr); + testResize(bspec256, bspec256, barr); + testResize(bspec256, bspec512, barr); + testResize(bspec512, bspec64, barr); + testResize(bspec512, bspec128, barr); + testResize(bspec512, bspec256, barr); + testResize(bspec512, bspec512, barr); + } + } + + @Test(dataProvider = "byteUnaryOpProvider", invocationCount = 2) + static void testResizeShort(IntFunction fa) { + byte[] barr = fa.apply(sspec64.elementSize()); + for (int i = 0; i < NUM_ITER; i++) { + testResize(sspec64, sspec64, barr); + testResize(sspec64, sspec128, barr); + testResize(sspec64, sspec256, barr); + testResize(sspec64, sspec512, barr); + testResize(sspec128, sspec64, barr); + testResize(sspec128, sspec128, barr); + testResize(sspec128, sspec256, barr); + testResize(sspec128, sspec512, barr); + testResize(sspec256, sspec64, barr); + testResize(sspec256, sspec128, barr); + testResize(sspec256, sspec256, barr); + testResize(sspec256, sspec512, barr); + testResize(sspec512, sspec64, barr); + testResize(sspec512, sspec128, barr); + testResize(sspec512, sspec256, barr); + testResize(sspec512, sspec512, barr); + } + } + + @Test(dataProvider = "byteUnaryOpProvider", invocationCount = 2) + static void testResizeInt(IntFunction fa) { + byte[] barr = fa.apply(ispec64.elementSize()); + for (int i = 0; i < NUM_ITER; i++) { + testResize(ispec64, ispec64, barr); + testResize(ispec64, ispec128, barr); + testResize(ispec64, ispec256, barr); + testResize(ispec64, ispec512, barr); + testResize(ispec128, ispec64, barr); + testResize(ispec128, ispec128, barr); + testResize(ispec128, ispec256, barr); + testResize(ispec128, ispec512, barr); + testResize(ispec256, ispec64, barr); + testResize(ispec256, ispec128, barr); + testResize(ispec256, ispec256, barr); + testResize(ispec256, ispec512, barr); + testResize(ispec512, ispec64, barr); + testResize(ispec512, ispec128, barr); + testResize(ispec512, ispec256, barr); + testResize(ispec512, ispec512, barr); + } + } + + @Test(dataProvider = "byteUnaryOpProvider", invocationCount = 2) + static void testResizeLong(IntFunction fa) { + byte[] barr = fa.apply(lspec64.elementSize()); + for (int i = 0; i < NUM_ITER; i++) { + testResize(lspec64, lspec64, barr); + testResize(lspec64, lspec128, barr); + testResize(lspec64, lspec256, barr); + testResize(lspec64, lspec512, barr); + testResize(lspec128, lspec64, barr); + testResize(lspec128, lspec128, barr); + testResize(lspec128, lspec256, barr); + testResize(lspec128, lspec512, barr); + testResize(lspec256, lspec64, barr); + testResize(lspec256, lspec128, barr); + testResize(lspec256, lspec256, barr); + testResize(lspec256, lspec512, barr); + testResize(lspec512, lspec64, barr); + testResize(lspec512, lspec128, barr); + testResize(lspec512, lspec256, barr); + testResize(lspec512, lspec512, barr); + } + } + + @Test(dataProvider = "byteUnaryOpProvider", invocationCount = 2) + static void testResizeFloat(IntFunction fa) { + byte[] barr = fa.apply(fspec64.elementSize()); + for (int i = 0; i < NUM_ITER; i++) { + testResize(fspec64, fspec64, barr); + testResize(fspec64, fspec128, barr); + testResize(fspec64, fspec256, barr); + testResize(fspec64, fspec512, barr); + testResize(fspec128, fspec64, barr); + testResize(fspec128, fspec128, barr); + testResize(fspec128, fspec256, barr); + testResize(fspec128, fspec512, barr); + testResize(fspec256, fspec64, barr); + testResize(fspec256, fspec128, barr); + testResize(fspec256, fspec256, barr); + testResize(fspec256, fspec512, barr); + testResize(fspec512, fspec64, barr); + testResize(fspec512, fspec128, barr); + testResize(fspec512, fspec256, barr); + testResize(fspec512, fspec512, barr); + } + } + + @Test(dataProvider = "byteUnaryOpProvider", invocationCount = 2) + static void testResizeDouble(IntFunction fa) { + byte[] barr = fa.apply(dspec64.elementSize()); + for (int i = 0; i < NUM_ITER; i++) { + testResize(dspec64, dspec64, barr); + testResize(dspec64, dspec128, barr); + testResize(dspec64, dspec256, barr); + testResize(dspec64, dspec512, barr); + testResize(dspec128, dspec64, barr); + testResize(dspec128, dspec128, barr); + testResize(dspec128, dspec256, barr); + testResize(dspec128, dspec512, barr); + testResize(dspec256, dspec64, barr); + testResize(dspec256, dspec128, barr); + testResize(dspec256, dspec256, barr); + testResize(dspec256, dspec512, barr); + testResize(dspec512, dspec64, barr); + testResize(dspec512, dspec128, barr); + testResize(dspec512, dspec256, barr); + testResize(dspec512, dspec512, barr); + } + } +}