8277997: Intrinsic creation for VectorMask.fromLong API

Reviewed-by: psandoz, kvn, sviswanathan
This commit is contained in:
Jatin Bhateja 2021-12-10 01:49:20 +00:00
parent 066b348dbc
commit 0113322ac1
81 changed files with 595 additions and 242 deletions

View File

@ -11292,6 +11292,20 @@ void Assembler::bzhiq(Register dst, Register src1, Register src2) {
emit_int16((unsigned char)0xF5, (0xC0 | encode)); emit_int16((unsigned char)0xF5, (0xC0 | encode));
} }
void Assembler::pext(Register dst, Register src1, Register src2) {
assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported");
InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
int encode = vex_prefix_and_encode(dst->encoding(), src1->encoding(), src2->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes);
emit_int16((unsigned char)0xF5, (0xC0 | encode));
}
void Assembler::pdep(Register dst, Register src1, Register src2) {
assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported");
InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
int encode = vex_prefix_and_encode(dst->encoding(), src1->encoding(), src2->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F_38, &attributes);
emit_int16((unsigned char)0xF5, (0xC0 | encode));
}
void Assembler::shlxl(Register dst, Register src1, Register src2) { void Assembler::shlxl(Register dst, Register src1, Register src2) {
assert(VM_Version::supports_bmi2(), ""); assert(VM_Version::supports_bmi2(), "");
InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true); InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true);

View File

@ -2184,6 +2184,9 @@ private:
void shrxq(Register dst, Register src1, Register src2); void shrxq(Register dst, Register src1, Register src2);
void bzhiq(Register dst, Register src1, Register src2); void bzhiq(Register dst, Register src1, Register src2);
void pdep(Register dst, Register src1, Register src2);
void pext(Register dst, Register src1, Register src2);
//====================VECTOR ARITHMETIC===================================== //====================VECTOR ARITHMETIC=====================================
// Add Packed Floating-Point Values // Add Packed Floating-Point Values

View File

@ -4153,6 +4153,45 @@ void C2_MacroAssembler::vector_castF2I_evex(XMMRegister dst, XMMRegister src, XM
} }
#ifdef _LP64 #ifdef _LP64
void C2_MacroAssembler::vector_long_to_maskvec(XMMRegister dst, Register src, Register rtmp1,
Register rtmp2, XMMRegister xtmp, int mask_len,
int vec_enc) {
int index = 0;
int vindex = 0;
mov64(rtmp1, 0x0101010101010101L);
pdep(rtmp1, src, rtmp1);
if (mask_len > 8) {
movq(rtmp2, src);
vpxor(xtmp, xtmp, xtmp, vec_enc);
movq(xtmp, rtmp1);
}
movq(dst, rtmp1);
mask_len -= 8;
while (mask_len > 0) {
assert ((mask_len & 0x7) == 0, "mask must be multiple of 8");
index++;
if ((index % 2) == 0) {
pxor(xtmp, xtmp);
}
mov64(rtmp1, 0x0101010101010101L);
shrq(rtmp2, 8);
pdep(rtmp1, rtmp2, rtmp1);
pinsrq(xtmp, rtmp1, index % 2);
vindex = index / 2;
if (vindex) {
// Write entire 16 byte vector when both 64 bit
// lanes are update to save redundant instructions.
if (index % 2) {
vinsertf128(dst, dst, xtmp, vindex);
}
} else {
vmovdqu(dst, xtmp);
}
mask_len -= 8;
}
}
void C2_MacroAssembler::vector_mask_operation_helper(int opc, Register dst, Register tmp, int masklen) { void C2_MacroAssembler::vector_mask_operation_helper(int opc, Register dst, Register tmp, int masklen) {
switch(opc) { switch(opc) {
case Op_VectorMaskTrueCount: case Op_VectorMaskTrueCount:

View File

@ -230,7 +230,10 @@ public:
void vector_mask_operation(int opc, Register dst, XMMRegister mask, XMMRegister xtmp, void vector_mask_operation(int opc, Register dst, XMMRegister mask, XMMRegister xtmp,
Register tmp, int masklen, BasicType bt, int vec_enc); Register tmp, int masklen, BasicType bt, int vec_enc);
void vector_long_to_maskvec(XMMRegister dst, Register src, Register rtmp1,
Register rtmp2, XMMRegister xtmp, int mask_len, int vec_enc);
#endif #endif
void string_indexof_char(Register str1, Register cnt1, Register ch, Register result, void string_indexof_char(Register str1, Register cnt1, Register ch, Register result,
XMMRegister vec1, XMMRegister vec2, XMMRegister vec3, Register tmp); XMMRegister vec1, XMMRegister vec2, XMMRegister vec3, Register tmp);

View File

@ -1842,6 +1842,14 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType
return false; return false;
} }
break; break;
case Op_VectorLongToMask:
if (UseAVX < 1 || !is_LP64) {
return false;
}
if (UseAVX < 3 && !VM_Version::supports_bmi2()) {
return false;
}
break;
} }
return true; // Per default match rules are supported. return true; // Per default match rules are supported.
} }
@ -9533,6 +9541,47 @@ instruct mask_not_imm(kReg dst, kReg src, immI_M1 cnt) %{
%} %}
ins_pipe( pipe_slow ); ins_pipe( pipe_slow );
%} %}
instruct long_to_maskLE8_avx(vec dst, rRegL src, rRegL rtmp1, rRegL rtmp2, vec xtmp) %{
predicate(n->bottom_type()->isa_vectmask() == NULL && Matcher::vector_length(n) <= 8);
match(Set dst (VectorLongToMask src));
effect(TEMP dst, TEMP rtmp1, TEMP rtmp2, TEMP xtmp);
format %{ "long_to_mask_avx $dst, $src\t! using $rtmp1, $rtmp2, $xtmp as TEMP" %}
ins_encode %{
int mask_len = Matcher::vector_length(this);
int vec_enc = vector_length_encoding(mask_len*8);
__ vector_long_to_maskvec($dst$$XMMRegister, $src$$Register, $rtmp1$$Register,
$rtmp2$$Register, xnoreg, mask_len, vec_enc);
%}
ins_pipe( pipe_slow );
%}
instruct long_to_maskGT8_avx(vec dst, rRegL src, rRegL rtmp1, rRegL rtmp2, vec xtmp1, rFlagsReg cr) %{
predicate(n->bottom_type()->isa_vectmask() == NULL && Matcher::vector_length(n) > 8);
match(Set dst (VectorLongToMask src));
effect(TEMP dst, TEMP rtmp1, TEMP rtmp2, TEMP xtmp1, KILL cr);
format %{ "long_to_mask_avx $dst, $src\t! using $rtmp1, $rtmp2, $xtmp1, as TEMP" %}
ins_encode %{
int mask_len = Matcher::vector_length(this);
assert(mask_len <= 32, "invalid mask length");
int vec_enc = vector_length_encoding(mask_len*8);
__ vector_long_to_maskvec($dst$$XMMRegister, $src$$Register, $rtmp1$$Register,
$rtmp2$$Register, $xtmp1$$XMMRegister, mask_len, vec_enc);
%}
ins_pipe( pipe_slow );
%}
instruct long_to_mask_evex(kReg dst, rRegL src) %{
predicate(n->bottom_type()->isa_vectmask());
match(Set dst (VectorLongToMask src));
format %{ "long_to_mask_evex $dst, $src\t!" %}
ins_encode %{
int mask_len = Matcher::vector_length(this);
__ kmov($dst$$KRegister, $src$$Register);
%}
ins_pipe( pipe_slow );
%}
#endif #endif
instruct mask_opers_evex(kReg dst, kReg src1, kReg src2, kReg kscratch) %{ instruct mask_opers_evex(kReg dst, kReg src1, kReg src2, kReg kscratch) %{
@ -9552,6 +9601,7 @@ instruct mask_opers_evex(kReg dst, kReg src1, kReg src2, kReg kscratch) %{
ins_pipe( pipe_slow ); ins_pipe( pipe_slow );
%} %}
instruct castMM(kReg dst) instruct castMM(kReg dst)
%{ %{
match(Set dst (CastVV dst)); match(Set dst (CastVV dst));

View File

@ -4234,8 +4234,8 @@ bool MatchRule::is_vector() const {
"VectorRearrange","VectorLoadShuffle", "VectorLoadConst", "VectorRearrange","VectorLoadShuffle", "VectorLoadConst",
"VectorCastB2X", "VectorCastS2X", "VectorCastI2X", "VectorCastB2X", "VectorCastS2X", "VectorCastI2X",
"VectorCastL2X", "VectorCastF2X", "VectorCastD2X", "VectorCastL2X", "VectorCastF2X", "VectorCastD2X",
"VectorMaskWrapper", "VectorMaskCmp", "VectorReinterpret","LoadVectorMasked","StoreVectorMasked", "VectorMaskWrapper","VectorMaskCmp","VectorReinterpret","LoadVectorMasked","StoreVectorMasked",
"FmaVD", "FmaVF","PopCountVI", "FmaVD","FmaVF","PopCountVI","VectorLongToMask",
// Next are vector mask ops. // Next are vector mask ops.
"MaskAll", "AndVMask", "OrVMask", "XorVMask", "VectorMaskCast", "MaskAll", "AndVMask", "OrVMask", "XorVMask", "VectorMaskCast",
// Next are not supported currently. // Next are not supported currently.

View File

@ -869,15 +869,16 @@ class methodHandle;
"Ljdk/internal/vm/vector/VectorSupport$Vector;") \ "Ljdk/internal/vm/vector/VectorSupport$Vector;") \
do_name(vector_ternary_op_name, "ternaryOp") \ do_name(vector_ternary_op_name, "ternaryOp") \
\ \
do_intrinsic(_VectorBroadcastCoerced, jdk_internal_vm_vector_VectorSupport, vector_broadcast_coerced_name, vector_broadcast_coerced_sig, F_S)\ do_intrinsic(_VectorFromBitsCoerced, jdk_internal_vm_vector_VectorSupport, vector_frombits_coerced_name, vector_frombits_coerced_sig, F_S) \
do_signature(vector_broadcast_coerced_sig, "(Ljava/lang/Class;" \ do_signature(vector_frombits_coerced_sig, "(Ljava/lang/Class;" \
"Ljava/lang/Class;" \ "Ljava/lang/Class;" \
"I" \ "I" \
"J" \ "J" \
"I" \
"Ljdk/internal/vm/vector/VectorSupport$VectorSpecies;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorSpecies;" \
"Ljdk/internal/vm/vector/VectorSupport$BroadcastOperation;)" \ "Ljdk/internal/vm/vector/VectorSupport$FromBitsCoercedOperation;)" \
"Ljdk/internal/vm/vector/VectorSupport$VectorPayload;") \ "Ljdk/internal/vm/vector/VectorSupport$VectorPayload;") \
do_name(vector_broadcast_coerced_name, "broadcastCoerced") \ do_name(vector_frombits_coerced_name, "fromBitsCoerced") \
\ \
do_intrinsic(_VectorShuffleIota, jdk_internal_vm_vector_VectorSupport, vector_shuffle_step_iota_name, vector_shuffle_step_iota_sig, F_S) \ do_intrinsic(_VectorShuffleIota, jdk_internal_vm_vector_VectorSupport, vector_shuffle_step_iota_name, vector_shuffle_step_iota_sig, F_S) \
do_signature(vector_shuffle_step_iota_sig, "(Ljava/lang/Class;" \ do_signature(vector_shuffle_step_iota_sig, "(Ljava/lang/Class;" \

View File

@ -690,7 +690,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
case vmIntrinsics::_VectorUnaryOp: case vmIntrinsics::_VectorUnaryOp:
case vmIntrinsics::_VectorBinaryOp: case vmIntrinsics::_VectorBinaryOp:
case vmIntrinsics::_VectorTernaryOp: case vmIntrinsics::_VectorTernaryOp:
case vmIntrinsics::_VectorBroadcastCoerced: case vmIntrinsics::_VectorFromBitsCoerced:
case vmIntrinsics::_VectorShuffleIota: case vmIntrinsics::_VectorShuffleIota:
case vmIntrinsics::_VectorShuffleToVector: case vmIntrinsics::_VectorShuffleToVector:
case vmIntrinsics::_VectorLoadOp: case vmIntrinsics::_VectorLoadOp:

View File

@ -428,6 +428,7 @@ macro(VectorMaskTrueCount)
macro(VectorMaskFirstTrue) macro(VectorMaskFirstTrue)
macro(VectorMaskLastTrue) macro(VectorMaskLastTrue)
macro(VectorMaskToLong) macro(VectorMaskToLong)
macro(VectorLongToMask)
macro(Pack) macro(Pack)
macro(PackB) macro(PackB)
macro(PackS) macro(PackS)

View File

@ -652,8 +652,8 @@ bool LibraryCallKit::try_to_inline(int predicate) {
return inline_vector_nary_operation(2); return inline_vector_nary_operation(2);
case vmIntrinsics::_VectorTernaryOp: case vmIntrinsics::_VectorTernaryOp:
return inline_vector_nary_operation(3); return inline_vector_nary_operation(3);
case vmIntrinsics::_VectorBroadcastCoerced: case vmIntrinsics::_VectorFromBitsCoerced:
return inline_vector_broadcast_coerced(); return inline_vector_frombits_coerced();
case vmIntrinsics::_VectorShuffleIota: case vmIntrinsics::_VectorShuffleIota:
return inline_vector_shuffle_iota(); return inline_vector_shuffle_iota();
case vmIntrinsics::_VectorMaskOp: case vmIntrinsics::_VectorMaskOp:

View File

@ -314,7 +314,7 @@ class LibraryCallKit : public GraphKit {
// Vector API support // Vector API support
bool inline_vector_nary_operation(int n); bool inline_vector_nary_operation(int n);
bool inline_vector_broadcast_coerced(); bool inline_vector_frombits_coerced();
bool inline_vector_shuffle_to_vector(); bool inline_vector_shuffle_to_vector();
bool inline_vector_shuffle_iota(); bool inline_vector_shuffle_iota();
bool inline_vector_mask_operation(); bool inline_vector_mask_operation();

View File

@ -789,21 +789,28 @@ bool LibraryCallKit::inline_vector_shuffle_to_vector() {
// <M, // <M,
// S extends VectorSpecies<E>, // S extends VectorSpecies<E>,
// E> // E>
// M broadcastCoerced(Class<? extends M> vmClass, Class<E> elementType, int length, // M fromBitsCoerced(Class<? extends M> vmClass, Class<E> elementType, int length,
// long bits, S s, // long bits, int mode, S s,
// BroadcastOperation<M, E, S> defaultImpl) // BroadcastOperation<M, E, S> defaultImpl)
bool LibraryCallKit::inline_vector_broadcast_coerced() { bool LibraryCallKit::inline_vector_frombits_coerced() {
const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr();
const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr();
const TypeInt* vlen = gvn().type(argument(2))->isa_int(); const TypeInt* vlen = gvn().type(argument(2))->isa_int();
const TypeLong* bits_type = gvn().type(argument(3))->isa_long();
// Mode argument determines the mode of operation it can take following values:-
// MODE_BROADCAST for vector Vector.boradcast and VectorMask.maskAll operations.
// MODE_BITS_COERCED_LONG_TO_MASK for VectorMask.fromLong operation.
const TypeInt* mode = gvn().type(argument(5))->isa_int();
if (vector_klass == NULL || elem_klass == NULL || vlen == NULL || if (vector_klass == NULL || elem_klass == NULL || vlen == NULL || mode == NULL ||
vector_klass->const_oop() == NULL || elem_klass->const_oop() == NULL || !vlen->is_con()) { bits_type == NULL || vector_klass->const_oop() == NULL || elem_klass->const_oop() == NULL ||
!vlen->is_con() || !mode->is_con()) {
if (C->print_intrinsics()) { if (C->print_intrinsics()) {
tty->print_cr(" ** missing constant: vclass=%s etype=%s vlen=%s", tty->print_cr(" ** missing constant: vclass=%s etype=%s vlen=%s bitwise=%s",
NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(0)->Opcode()],
NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(1)->Opcode()],
NodeClassNames[argument(2)->Opcode()]); NodeClassNames[argument(2)->Opcode()],
NodeClassNames[argument(5)->Opcode()]);
} }
return false; // not enough info for intrinsification return false; // not enough info for intrinsification
} }
@ -826,46 +833,62 @@ bool LibraryCallKit::inline_vector_broadcast_coerced() {
ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass();
const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass);
// TODO When mask usage is supported, VecMaskNotUsed needs to be VecMaskUseLoad. bool is_mask = is_vector_mask(vbox_klass);
if (!arch_supports_vector(VectorNode::replicate_opcode(elem_bt), num_elem, elem_bt, int bcast_mode = mode->get_con();
(is_vector_mask(vbox_klass) ? VecMaskUseStore : VecMaskNotUsed), true /*has_scalar_args*/)) { VectorMaskUseType checkFlags = (VectorMaskUseType)(is_mask ? VecMaskUseAll : VecMaskNotUsed);
int opc = bcast_mode == VectorSupport::MODE_BITS_COERCED_LONG_TO_MASK ? Op_VectorLongToMask : VectorNode::replicate_opcode(elem_bt);
if (!arch_supports_vector(opc, num_elem, elem_bt, checkFlags, true /*has_scalar_args*/)) {
if (C->print_intrinsics()) { if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: arity=0 op=broadcast vlen=%d etype=%s ismask=%d", tty->print_cr(" ** not supported: arity=0 op=broadcast vlen=%d etype=%s ismask=%d bcast_mode=%d",
num_elem, type2name(elem_bt), num_elem, type2name(elem_bt),
is_vector_mask(vbox_klass) ? 1 : 0); is_mask ? 1 : 0,
bcast_mode);
} }
return false; // not supported return false; // not supported
} }
Node* bits = argument(3); // long Node* broadcast = NULL;
Node* elem = NULL; Node* bits = argument(3);
switch (elem_bt) { Node* elem = bits;
case T_BOOLEAN: // fall-through
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_CHAR: // fall-through
case T_INT: {
elem = gvn().transform(new ConvL2INode(bits));
break;
}
case T_DOUBLE: {
elem = gvn().transform(new MoveL2DNode(bits));
break;
}
case T_FLOAT: {
bits = gvn().transform(new ConvL2INode(bits));
elem = gvn().transform(new MoveI2FNode(bits));
break;
}
case T_LONG: {
elem = bits; // no conversion needed
break;
}
default: fatal("%s", type2name(elem_bt));
}
Node* broadcast = VectorNode::scalar2vector(elem, num_elem, Type::get_const_basic_type(elem_bt), is_vector_mask(vbox_klass)); if (opc == Op_VectorLongToMask) {
broadcast = gvn().transform(broadcast); const TypeVect* vt = TypeVect::makemask(elem_bt, num_elem);
if (vt->isa_vectmask()) {
broadcast = gvn().transform(new VectorLongToMaskNode(elem, vt));
} else {
const TypeVect* mvt = TypeVect::make(T_BOOLEAN, num_elem);
broadcast = gvn().transform(new VectorLongToMaskNode(elem, mvt));
broadcast = gvn().transform(new VectorLoadMaskNode(broadcast, vt));
}
} else {
switch (elem_bt) {
case T_BOOLEAN: // fall-through
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_CHAR: // fall-through
case T_INT: {
elem = gvn().transform(new ConvL2INode(bits));
break;
}
case T_DOUBLE: {
elem = gvn().transform(new MoveL2DNode(bits));
break;
}
case T_FLOAT: {
bits = gvn().transform(new ConvL2INode(bits));
elem = gvn().transform(new MoveI2FNode(bits));
break;
}
case T_LONG: {
// no conversion needed
break;
}
default: fatal("%s", type2name(elem_bt));
}
broadcast = VectorNode::scalar2vector(elem, num_elem, Type::get_const_basic_type(elem_bt), is_mask);
broadcast = gvn().transform(broadcast);
}
Node* box = box_vector(broadcast, vbox_type, elem_bt, num_elem); Node* box = box_vector(broadcast, vbox_type, elem_bt, num_elem);
set_result(box); set_result(box);
@ -2493,21 +2516,7 @@ bool LibraryCallKit::inline_vector_convert() {
(type2aelembytes(elem_bt_from) == type2aelembytes(elem_bt_to))) { (type2aelembytes(elem_bt_from) == type2aelembytes(elem_bt_to))) {
op = gvn().transform(new VectorMaskCastNode(op, dst_type)); op = gvn().transform(new VectorMaskCastNode(op, dst_type));
} else { } else {
// Special handling for casting operation involving floating point types. op = VectorMaskCastNode::makeCastNode(&gvn(), op, dst_type);
// Case A) F -> X := F -> VectorMaskCast (F->I/L [NOP]) -> VectorCast[I/L]2X
// Case B) X -> F := X -> VectorCastX2[I/L] -> VectorMaskCast ([I/L]->F [NOP])
// Case C) F -> F := VectorMaskCast (F->I/L [NOP]) -> VectorCast[I/L]2[L/I] -> VectotMaskCast (L/I->F [NOP])
if (is_floating_point_type(elem_bt_from)) {
const TypeVect* new_src_type = TypeVect::make(new_elem_bt_from, num_elem_to, is_mask);
op = gvn().transform(new VectorMaskCastNode(op, new_src_type));
}
if (is_floating_point_type(elem_bt_to)) {
new_elem_bt_to = elem_bt_to == T_FLOAT ? T_INT : T_LONG;
}
op = gvn().transform(VectorCastNode::make(cast_vopc, op, new_elem_bt_to, num_elem_to));
if (new_elem_bt_to != elem_bt_to) {
op = gvn().transform(new VectorMaskCastNode(op, dst_type));
}
} }
} else { } else {
// Since input and output number of elements match, and since we know this vector size is // Since input and output number of elements match, and since we know this vector size is

View File

@ -1447,6 +1447,82 @@ Node* VectorMaskOpNode::make(Node* mask, const Type* ty, int mopc) {
return NULL; return NULL;
} }
Node* VectorMaskToLongNode::Identity(PhaseGVN* phase) {
if (in(1)->Opcode() == Op_VectorLongToMask) {
return in(1)->in(1);
}
return this;
}
Node* VectorMaskCastNode::makeCastNode(PhaseGVN* phase, Node* src, const TypeVect* dst_type) {
const TypeVect* src_type = src->bottom_type()->is_vect();
assert(src_type->length() == dst_type->length(), "");
int num_elem = src_type->length();
BasicType elem_bt_from = src_type->element_basic_type();
BasicType elem_bt_to = dst_type->element_basic_type();
if (dst_type->isa_vectmask() == NULL && src_type->isa_vectmask() == NULL &&
type2aelembytes(elem_bt_from) != type2aelembytes(elem_bt_to)) {
Node* op = src;
BasicType new_elem_bt_from = elem_bt_from;
BasicType new_elem_bt_to = elem_bt_to;
if (is_floating_point_type(elem_bt_from)) {
new_elem_bt_from = elem_bt_from == T_FLOAT ? T_INT : T_LONG;
}
if (is_floating_point_type(elem_bt_to)) {
new_elem_bt_to = elem_bt_to == T_FLOAT ? T_INT : T_LONG;
}
// Special handling for casting operation involving floating point types.
// Case A) F -> X := F -> VectorMaskCast (F->I/L [NOP]) -> VectorCast[I/L]2X
// Case B) X -> F := X -> VectorCastX2[I/L] -> VectorMaskCast ([I/L]->F [NOP])
// Case C) F -> F := VectorMaskCast (F->I/L [NOP]) -> VectorCast[I/L]2[L/I] -> VectotMaskCast (L/I->F [NOP])
if (new_elem_bt_from != elem_bt_from) {
const TypeVect* new_src_type = TypeVect::makemask(new_elem_bt_from, num_elem);
op = phase->transform(new VectorMaskCastNode(op, new_src_type));
}
op = phase->transform(VectorCastNode::make(VectorCastNode::opcode(new_elem_bt_from), op, new_elem_bt_to, num_elem));
if (new_elem_bt_to != elem_bt_to) {
op = phase->transform(new VectorMaskCastNode(op, dst_type));
}
return op;
} else {
return new VectorMaskCastNode(src, dst_type);
}
}
Node* VectorLongToMaskNode::Ideal(PhaseGVN* phase, bool can_reshape) {
const TypeVect* dst_type = bottom_type()->is_vect();
if (in(1)->Opcode() == Op_AndL &&
in(1)->in(1)->Opcode() == Op_VectorMaskToLong &&
in(1)->in(2)->bottom_type()->isa_long() &&
in(1)->in(2)->bottom_type()->is_long()->is_con() &&
in(1)->in(2)->bottom_type()->is_long()->get_con() == ((1L << dst_type->length()) - 1)) {
// Different src/dst mask length represents a re-interpretation operation,
// we can however generate a mask casting operation if length matches.
Node* src = in(1)->in(1)->in(1);
if (dst_type->isa_vectmask() == NULL) {
if (src->Opcode() != Op_VectorStoreMask) {
return NULL;
}
src = src->in(1);
}
const TypeVect* src_type = src->bottom_type()->is_vect();
if (src_type->length() == dst_type->length() &&
((src_type->isa_vectmask() == NULL && dst_type->isa_vectmask() == NULL) ||
(src_type->isa_vectmask() && dst_type->isa_vectmask()))) {
return VectorMaskCastNode::makeCastNode(phase, src, dst_type);
}
}
return NULL;
}
#ifndef PRODUCT #ifndef PRODUCT
void VectorBoxAllocateNode::dump_spec(outputStream *st) const { void VectorBoxAllocateNode::dump_spec(outputStream *st) const {
CallStaticJavaNode::dump_spec(st); CallStaticJavaNode::dump_spec(st);

View File

@ -29,6 +29,7 @@
#include "opto/memnode.hpp" #include "opto/memnode.hpp"
#include "opto/node.hpp" #include "opto/node.hpp"
#include "opto/opcodes.hpp" #include "opto/opcodes.hpp"
#include "prims/vectorSupport.hpp"
//------------------------------VectorNode------------------------------------- //------------------------------VectorNode-------------------------------------
// Vector Operation // Vector Operation
@ -977,6 +978,16 @@ class VectorMaskToLongNode : public VectorMaskOpNode {
VectorMaskOpNode(mask, ty, Op_VectorMaskToLong) {} VectorMaskOpNode(mask, ty, Op_VectorMaskToLong) {}
virtual int Opcode() const; virtual int Opcode() const;
virtual uint ideal_reg() const { return Op_RegL; } virtual uint ideal_reg() const { return Op_RegL; }
virtual Node* Identity(PhaseGVN* phase);
};
class VectorLongToMaskNode : public VectorNode {
public:
VectorLongToMaskNode(Node* mask, const TypeVect* ty):
VectorNode(mask, ty) {
}
virtual int Opcode() const;
Node* Ideal(PhaseGVN* phase, bool can_reshape);
}; };
//-------------------------- Vector mask broadcast ----------------------------------- //-------------------------- Vector mask broadcast -----------------------------------
@ -1401,7 +1412,7 @@ class VectorMaskCastNode : public VectorNode {
const TypeVect* in_vt = in->bottom_type()->is_vect(); const TypeVect* in_vt = in->bottom_type()->is_vect();
assert(in_vt->length() == vt->length(), "vector length must match"); assert(in_vt->length() == vt->length(), "vector length must match");
} }
static Node* makeCastNode(PhaseGVN* phase, Node* in1, const TypeVect * vt);
virtual int Opcode() const; virtual int Opcode() const;
}; };

View File

@ -121,6 +121,11 @@ class VectorSupport : AllStatic {
NUM_VEC_SIZES = 4 NUM_VEC_SIZES = 4
}; };
enum {
MODE_BROADCAST = 0,
MODE_BITS_COERCED_LONG_TO_MASK = 1
};
static const char* svmlname[VectorSupport::NUM_SVML_OP]; static const char* svmlname[VectorSupport::NUM_SVML_OP];
static int vop2ideal(jint vop, BasicType bt); static int vop2ideal(jint vop, BasicType bt);

View File

@ -114,6 +114,10 @@ public class VectorSupport {
public static final int BT_ult = BT_lt | BT_unsigned_compare; public static final int BT_ult = BT_lt | BT_unsigned_compare;
public static final int BT_ugt = BT_gt | BT_unsigned_compare; public static final int BT_ugt = BT_gt | BT_unsigned_compare;
// Various broadcasting modes.
public static final int MODE_BROADCAST = 0;
public static final int MODE_BITS_COERCED_LONG_TO_MASK = 1;
// BasicType codes, for primitives only: // BasicType codes, for primitives only:
public static final int public static final int
T_FLOAT = 6, T_FLOAT = 6,
@ -157,9 +161,9 @@ public class VectorSupport {
} }
/* ============================================================================ */ /* ============================================================================ */
public interface BroadcastOperation<VM extends VectorPayload, public interface FromBitsCoercedOperation<VM extends VectorPayload,
S extends VectorSpecies<?>> { S extends VectorSpecies<?>> {
VM broadcast(long l, S s); VM fromBits(long l, S s);
} }
@IntrinsicCandidate @IntrinsicCandidate
@ -167,12 +171,12 @@ public class VectorSupport {
<VM extends VectorPayload, <VM extends VectorPayload,
S extends VectorSpecies<E>, S extends VectorSpecies<E>,
E> E>
VM broadcastCoerced(Class<? extends VM> vmClass, Class<E> eClass, VM fromBitsCoerced(Class<? extends VM> vmClass, Class<E> eClass,
int length, int length,
long bits, S s, long bits, int mode, S s,
BroadcastOperation<VM, S> defaultImpl) { FromBitsCoercedOperation<VM, S> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl; assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.broadcast(bits, s); return defaultImpl.fromBits(bits, s);
} }
/* ============================================================================ */ /* ============================================================================ */

View File

@ -757,9 +757,9 @@ final class Byte128Vector extends ByteVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Byte128Mask maskAll(boolean bit) { static Byte128Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Byte128Mask.class, byte.class, VLENGTH, return VectorSupport.fromBitsCoerced(Byte128Mask.class, byte.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Byte128Mask TRUE_MASK = new Byte128Mask(true); private static final Byte128Mask TRUE_MASK = new Byte128Mask(true);
private static final Byte128Mask FALSE_MASK = new Byte128Mask(false); private static final Byte128Mask FALSE_MASK = new Byte128Mask(false);

View File

@ -789,9 +789,9 @@ final class Byte256Vector extends ByteVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Byte256Mask maskAll(boolean bit) { static Byte256Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Byte256Mask.class, byte.class, VLENGTH, return VectorSupport.fromBitsCoerced(Byte256Mask.class, byte.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Byte256Mask TRUE_MASK = new Byte256Mask(true); private static final Byte256Mask TRUE_MASK = new Byte256Mask(true);
private static final Byte256Mask FALSE_MASK = new Byte256Mask(false); private static final Byte256Mask FALSE_MASK = new Byte256Mask(false);

View File

@ -853,9 +853,9 @@ final class Byte512Vector extends ByteVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Byte512Mask maskAll(boolean bit) { static Byte512Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Byte512Mask.class, byte.class, VLENGTH, return VectorSupport.fromBitsCoerced(Byte512Mask.class, byte.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Byte512Mask TRUE_MASK = new Byte512Mask(true); private static final Byte512Mask TRUE_MASK = new Byte512Mask(true);
private static final Byte512Mask FALSE_MASK = new Byte512Mask(false); private static final Byte512Mask FALSE_MASK = new Byte512Mask(false);

View File

@ -741,9 +741,9 @@ final class Byte64Vector extends ByteVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Byte64Mask maskAll(boolean bit) { static Byte64Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Byte64Mask.class, byte.class, VLENGTH, return VectorSupport.fromBitsCoerced(Byte64Mask.class, byte.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Byte64Mask TRUE_MASK = new Byte64Mask(true); private static final Byte64Mask TRUE_MASK = new Byte64Mask(true);
private static final Byte64Mask FALSE_MASK = new Byte64Mask(false); private static final Byte64Mask FALSE_MASK = new Byte64Mask(false);

View File

@ -727,9 +727,9 @@ final class ByteMaxVector extends ByteVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static ByteMaxMask maskAll(boolean bit) { static ByteMaxMask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(ByteMaxMask.class, byte.class, VLENGTH, return VectorSupport.fromBitsCoerced(ByteMaxMask.class, byte.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final ByteMaxMask TRUE_MASK = new ByteMaxMask(true); private static final ByteMaxMask TRUE_MASK = new ByteMaxMask(true);
private static final ByteMaxMask FALSE_MASK = new ByteMaxMask(false); private static final ByteMaxMask FALSE_MASK = new ByteMaxMask(false);

View File

@ -455,8 +455,8 @@ public abstract class ByteVector extends AbstractVector<Byte> {
@ForceInline @ForceInline
public static ByteVector zero(VectorSpecies<Byte> species) { public static ByteVector zero(VectorSpecies<Byte> species) {
ByteSpecies vsp = (ByteSpecies) species; ByteSpecies vsp = (ByteSpecies) species;
return VectorSupport.broadcastCoerced(vsp.vectorType(), byte.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), byte.class, species.length(),
0, vsp, 0, MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
} }
@ -4149,9 +4149,9 @@ public abstract class ByteVector extends AbstractVector<Byte> {
@ForceInline @ForceInline
final ByteVector broadcastBits(long bits) { final ByteVector broadcastBits(long bits) {
return (ByteVector) return (ByteVector)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, byte.class, laneCount, vectorType, byte.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -718,9 +718,9 @@ final class Double128Vector extends DoubleVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Double128Mask maskAll(boolean bit) { static Double128Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Double128Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Double128Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Double128Mask TRUE_MASK = new Double128Mask(true); private static final Double128Mask TRUE_MASK = new Double128Mask(true);
private static final Double128Mask FALSE_MASK = new Double128Mask(false); private static final Double128Mask FALSE_MASK = new Double128Mask(false);

View File

@ -722,9 +722,9 @@ final class Double256Vector extends DoubleVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Double256Mask maskAll(boolean bit) { static Double256Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Double256Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Double256Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Double256Mask TRUE_MASK = new Double256Mask(true); private static final Double256Mask TRUE_MASK = new Double256Mask(true);
private static final Double256Mask FALSE_MASK = new Double256Mask(false); private static final Double256Mask FALSE_MASK = new Double256Mask(false);

View File

@ -730,9 +730,9 @@ final class Double512Vector extends DoubleVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Double512Mask maskAll(boolean bit) { static Double512Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Double512Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Double512Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Double512Mask TRUE_MASK = new Double512Mask(true); private static final Double512Mask TRUE_MASK = new Double512Mask(true);
private static final Double512Mask FALSE_MASK = new Double512Mask(false); private static final Double512Mask FALSE_MASK = new Double512Mask(false);

View File

@ -716,9 +716,9 @@ final class Double64Vector extends DoubleVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Double64Mask maskAll(boolean bit) { static Double64Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Double64Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Double64Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Double64Mask TRUE_MASK = new Double64Mask(true); private static final Double64Mask TRUE_MASK = new Double64Mask(true);
private static final Double64Mask FALSE_MASK = new Double64Mask(false); private static final Double64Mask FALSE_MASK = new Double64Mask(false);

View File

@ -715,9 +715,9 @@ final class DoubleMaxVector extends DoubleVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static DoubleMaxMask maskAll(boolean bit) { static DoubleMaxMask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(DoubleMaxMask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(DoubleMaxMask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final DoubleMaxMask TRUE_MASK = new DoubleMaxMask(true); private static final DoubleMaxMask TRUE_MASK = new DoubleMaxMask(true);
private static final DoubleMaxMask FALSE_MASK = new DoubleMaxMask(false); private static final DoubleMaxMask FALSE_MASK = new DoubleMaxMask(false);

View File

@ -444,8 +444,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
@ForceInline @ForceInline
public static DoubleVector zero(VectorSpecies<Double> species) { public static DoubleVector zero(VectorSpecies<Double> species) {
DoubleSpecies vsp = (DoubleSpecies) species; DoubleSpecies vsp = (DoubleSpecies) species;
return VectorSupport.broadcastCoerced(vsp.vectorType(), double.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), double.class, species.length(),
toBits(0.0f), vsp, toBits(0.0f), MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
} }
@ -3754,9 +3754,9 @@ public abstract class DoubleVector extends AbstractVector<Double> {
@ForceInline @ForceInline
final DoubleVector broadcastBits(long bits) { final DoubleVector broadcastBits(long bits) {
return (DoubleVector) return (DoubleVector)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, double.class, laneCount, vectorType, double.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -722,9 +722,9 @@ final class Float128Vector extends FloatVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Float128Mask maskAll(boolean bit) { static Float128Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Float128Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Float128Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Float128Mask TRUE_MASK = new Float128Mask(true); private static final Float128Mask TRUE_MASK = new Float128Mask(true);
private static final Float128Mask FALSE_MASK = new Float128Mask(false); private static final Float128Mask FALSE_MASK = new Float128Mask(false);

View File

@ -730,9 +730,9 @@ final class Float256Vector extends FloatVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Float256Mask maskAll(boolean bit) { static Float256Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Float256Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Float256Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Float256Mask TRUE_MASK = new Float256Mask(true); private static final Float256Mask TRUE_MASK = new Float256Mask(true);
private static final Float256Mask FALSE_MASK = new Float256Mask(false); private static final Float256Mask FALSE_MASK = new Float256Mask(false);

View File

@ -746,9 +746,9 @@ final class Float512Vector extends FloatVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Float512Mask maskAll(boolean bit) { static Float512Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Float512Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Float512Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Float512Mask TRUE_MASK = new Float512Mask(true); private static final Float512Mask TRUE_MASK = new Float512Mask(true);
private static final Float512Mask FALSE_MASK = new Float512Mask(false); private static final Float512Mask FALSE_MASK = new Float512Mask(false);

View File

@ -718,9 +718,9 @@ final class Float64Vector extends FloatVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Float64Mask maskAll(boolean bit) { static Float64Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Float64Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Float64Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Float64Mask TRUE_MASK = new Float64Mask(true); private static final Float64Mask TRUE_MASK = new Float64Mask(true);
private static final Float64Mask FALSE_MASK = new Float64Mask(false); private static final Float64Mask FALSE_MASK = new Float64Mask(false);

View File

@ -715,9 +715,9 @@ final class FloatMaxVector extends FloatVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static FloatMaxMask maskAll(boolean bit) { static FloatMaxMask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(FloatMaxMask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(FloatMaxMask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final FloatMaxMask TRUE_MASK = new FloatMaxMask(true); private static final FloatMaxMask TRUE_MASK = new FloatMaxMask(true);
private static final FloatMaxMask FALSE_MASK = new FloatMaxMask(false); private static final FloatMaxMask FALSE_MASK = new FloatMaxMask(false);

View File

@ -444,8 +444,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
@ForceInline @ForceInline
public static FloatVector zero(VectorSpecies<Float> species) { public static FloatVector zero(VectorSpecies<Float> species) {
FloatSpecies vsp = (FloatSpecies) species; FloatSpecies vsp = (FloatSpecies) species;
return VectorSupport.broadcastCoerced(vsp.vectorType(), float.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), float.class, species.length(),
toBits(0.0f), vsp, toBits(0.0f), MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
} }
@ -3704,9 +3704,9 @@ public abstract class FloatVector extends AbstractVector<Float> {
@ForceInline @ForceInline
final FloatVector broadcastBits(long bits) { final FloatVector broadcastBits(long bits) {
return (FloatVector) return (FloatVector)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, float.class, laneCount, vectorType, float.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -733,9 +733,9 @@ final class Int128Vector extends IntVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Int128Mask maskAll(boolean bit) { static Int128Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Int128Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Int128Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Int128Mask TRUE_MASK = new Int128Mask(true); private static final Int128Mask TRUE_MASK = new Int128Mask(true);
private static final Int128Mask FALSE_MASK = new Int128Mask(false); private static final Int128Mask FALSE_MASK = new Int128Mask(false);

View File

@ -741,9 +741,9 @@ final class Int256Vector extends IntVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Int256Mask maskAll(boolean bit) { static Int256Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Int256Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Int256Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Int256Mask TRUE_MASK = new Int256Mask(true); private static final Int256Mask TRUE_MASK = new Int256Mask(true);
private static final Int256Mask FALSE_MASK = new Int256Mask(false); private static final Int256Mask FALSE_MASK = new Int256Mask(false);

View File

@ -757,9 +757,9 @@ final class Int512Vector extends IntVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Int512Mask maskAll(boolean bit) { static Int512Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Int512Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Int512Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Int512Mask TRUE_MASK = new Int512Mask(true); private static final Int512Mask TRUE_MASK = new Int512Mask(true);
private static final Int512Mask FALSE_MASK = new Int512Mask(false); private static final Int512Mask FALSE_MASK = new Int512Mask(false);

View File

@ -729,9 +729,9 @@ final class Int64Vector extends IntVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Int64Mask maskAll(boolean bit) { static Int64Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Int64Mask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(Int64Mask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Int64Mask TRUE_MASK = new Int64Mask(true); private static final Int64Mask TRUE_MASK = new Int64Mask(true);
private static final Int64Mask FALSE_MASK = new Int64Mask(false); private static final Int64Mask FALSE_MASK = new Int64Mask(false);

View File

@ -727,9 +727,9 @@ final class IntMaxVector extends IntVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static IntMaxMask maskAll(boolean bit) { static IntMaxMask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(IntMaxMask.class, int.class, VLENGTH, return VectorSupport.fromBitsCoerced(IntMaxMask.class, int.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final IntMaxMask TRUE_MASK = new IntMaxMask(true); private static final IntMaxMask TRUE_MASK = new IntMaxMask(true);
private static final IntMaxMask FALSE_MASK = new IntMaxMask(false); private static final IntMaxMask FALSE_MASK = new IntMaxMask(false);

View File

@ -455,8 +455,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
@ForceInline @ForceInline
public static IntVector zero(VectorSpecies<Integer> species) { public static IntVector zero(VectorSpecies<Integer> species) {
IntSpecies vsp = (IntSpecies) species; IntSpecies vsp = (IntSpecies) species;
return VectorSupport.broadcastCoerced(vsp.vectorType(), int.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), int.class, species.length(),
0, vsp, 0, MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
} }
@ -3874,9 +3874,9 @@ public abstract class IntVector extends AbstractVector<Integer> {
@ForceInline @ForceInline
final IntVector broadcastBits(long bits) { final IntVector broadcastBits(long bits) {
return (IntVector) return (IntVector)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, int.class, laneCount, vectorType, int.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -719,9 +719,9 @@ final class Long128Vector extends LongVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Long128Mask maskAll(boolean bit) { static Long128Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Long128Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Long128Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Long128Mask TRUE_MASK = new Long128Mask(true); private static final Long128Mask TRUE_MASK = new Long128Mask(true);
private static final Long128Mask FALSE_MASK = new Long128Mask(false); private static final Long128Mask FALSE_MASK = new Long128Mask(false);

View File

@ -723,9 +723,9 @@ final class Long256Vector extends LongVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Long256Mask maskAll(boolean bit) { static Long256Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Long256Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Long256Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Long256Mask TRUE_MASK = new Long256Mask(true); private static final Long256Mask TRUE_MASK = new Long256Mask(true);
private static final Long256Mask FALSE_MASK = new Long256Mask(false); private static final Long256Mask FALSE_MASK = new Long256Mask(false);

View File

@ -731,9 +731,9 @@ final class Long512Vector extends LongVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Long512Mask maskAll(boolean bit) { static Long512Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Long512Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Long512Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Long512Mask TRUE_MASK = new Long512Mask(true); private static final Long512Mask TRUE_MASK = new Long512Mask(true);
private static final Long512Mask FALSE_MASK = new Long512Mask(false); private static final Long512Mask FALSE_MASK = new Long512Mask(false);

View File

@ -717,9 +717,9 @@ final class Long64Vector extends LongVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Long64Mask maskAll(boolean bit) { static Long64Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Long64Mask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(Long64Mask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Long64Mask TRUE_MASK = new Long64Mask(true); private static final Long64Mask TRUE_MASK = new Long64Mask(true);
private static final Long64Mask FALSE_MASK = new Long64Mask(false); private static final Long64Mask FALSE_MASK = new Long64Mask(false);

View File

@ -717,9 +717,9 @@ final class LongMaxVector extends LongVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static LongMaxMask maskAll(boolean bit) { static LongMaxMask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(LongMaxMask.class, long.class, VLENGTH, return VectorSupport.fromBitsCoerced(LongMaxMask.class, long.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final LongMaxMask TRUE_MASK = new LongMaxMask(true); private static final LongMaxMask TRUE_MASK = new LongMaxMask(true);
private static final LongMaxMask FALSE_MASK = new LongMaxMask(false); private static final LongMaxMask FALSE_MASK = new LongMaxMask(false);

View File

@ -455,8 +455,8 @@ public abstract class LongVector extends AbstractVector<Long> {
@ForceInline @ForceInline
public static LongVector zero(VectorSpecies<Long> species) { public static LongVector zero(VectorSpecies<Long> species) {
LongSpecies vsp = (LongSpecies) species; LongSpecies vsp = (LongSpecies) species;
return VectorSupport.broadcastCoerced(vsp.vectorType(), long.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), long.class, species.length(),
0, vsp, 0, MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
} }
@ -3809,9 +3809,9 @@ public abstract class LongVector extends AbstractVector<Long> {
@ForceInline @ForceInline
final LongVector broadcastBits(long bits) { final LongVector broadcastBits(long bits) {
return (LongVector) return (LongVector)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, long.class, laneCount, vectorType, long.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -741,9 +741,9 @@ final class Short128Vector extends ShortVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Short128Mask maskAll(boolean bit) { static Short128Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Short128Mask.class, short.class, VLENGTH, return VectorSupport.fromBitsCoerced(Short128Mask.class, short.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Short128Mask TRUE_MASK = new Short128Mask(true); private static final Short128Mask TRUE_MASK = new Short128Mask(true);
private static final Short128Mask FALSE_MASK = new Short128Mask(false); private static final Short128Mask FALSE_MASK = new Short128Mask(false);

View File

@ -757,9 +757,9 @@ final class Short256Vector extends ShortVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Short256Mask maskAll(boolean bit) { static Short256Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Short256Mask.class, short.class, VLENGTH, return VectorSupport.fromBitsCoerced(Short256Mask.class, short.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Short256Mask TRUE_MASK = new Short256Mask(true); private static final Short256Mask TRUE_MASK = new Short256Mask(true);
private static final Short256Mask FALSE_MASK = new Short256Mask(false); private static final Short256Mask FALSE_MASK = new Short256Mask(false);

View File

@ -789,9 +789,9 @@ final class Short512Vector extends ShortVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Short512Mask maskAll(boolean bit) { static Short512Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Short512Mask.class, short.class, VLENGTH, return VectorSupport.fromBitsCoerced(Short512Mask.class, short.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Short512Mask TRUE_MASK = new Short512Mask(true); private static final Short512Mask TRUE_MASK = new Short512Mask(true);
private static final Short512Mask FALSE_MASK = new Short512Mask(false); private static final Short512Mask FALSE_MASK = new Short512Mask(false);

View File

@ -733,9 +733,9 @@ final class Short64Vector extends ShortVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static Short64Mask maskAll(boolean bit) { static Short64Mask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(Short64Mask.class, short.class, VLENGTH, return VectorSupport.fromBitsCoerced(Short64Mask.class, short.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final Short64Mask TRUE_MASK = new Short64Mask(true); private static final Short64Mask TRUE_MASK = new Short64Mask(true);
private static final Short64Mask FALSE_MASK = new Short64Mask(false); private static final Short64Mask FALSE_MASK = new Short64Mask(false);

View File

@ -727,9 +727,9 @@ final class ShortMaxVector extends ShortVector {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static ShortMaxMask maskAll(boolean bit) { static ShortMaxMask maskAll(boolean bit) {
return VectorSupport.broadcastCoerced(ShortMaxMask.class, short.class, VLENGTH, return VectorSupport.fromBitsCoerced(ShortMaxMask.class, short.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final ShortMaxMask TRUE_MASK = new ShortMaxMask(true); private static final ShortMaxMask TRUE_MASK = new ShortMaxMask(true);
private static final ShortMaxMask FALSE_MASK = new ShortMaxMask(false); private static final ShortMaxMask FALSE_MASK = new ShortMaxMask(false);

View File

@ -455,8 +455,8 @@ public abstract class ShortVector extends AbstractVector<Short> {
@ForceInline @ForceInline
public static ShortVector zero(VectorSpecies<Short> species) { public static ShortVector zero(VectorSpecies<Short> species) {
ShortSpecies vsp = (ShortSpecies) species; ShortSpecies vsp = (ShortSpecies) species;
return VectorSupport.broadcastCoerced(vsp.vectorType(), short.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), short.class, species.length(),
0, vsp, 0, MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
} }
@ -4143,9 +4143,9 @@ public abstract class ShortVector extends AbstractVector<Short> {
@ForceInline @ForceInline
final ShortVector broadcastBits(long bits) { final ShortVector broadcastBits(long bits) {
return (ShortVector) return (ShortVector)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, short.class, laneCount, vectorType, short.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -237,26 +237,25 @@ public abstract class VectorMask<E> extends jdk.internal.vm.vector.VectorSupport
*/ */
@ForceInline @ForceInline
public static <E> VectorMask<E> fromLong(VectorSpecies<E> species, long bits) { public static <E> VectorMask<E> fromLong(VectorSpecies<E> species, long bits) {
AbstractSpecies<E> vspecies = (AbstractSpecies<E>) species; AbstractSpecies<E> vsp = (AbstractSpecies<E>) species;
int laneCount = vspecies.laneCount(); bits = bits & (0xFFFFFFFFFFFFFFFFL >>> (64 - vsp.laneCount()));
if (laneCount < Long.SIZE) { return VectorSupport.fromBitsCoerced(vsp.maskType(), vsp.elementType(), vsp.laneCount(), bits,
int extraSignBits = Long.SIZE - laneCount; VectorSupport.MODE_BITS_COERCED_LONG_TO_MASK, vsp,
bits <<= extraSignBits; (m, s) -> {
bits >>= extraSignBits; if (m == (m >> 1)) {
} // Special case.
if (bits == (bits >> 1)) { assert(m == 0 || m == -1);
// Special case. return s.maskAll(m != 0);
assert(bits == 0 || bits == -1); }
return vspecies.maskAll(bits != 0);
} long shifted = m;
// FIXME: Intrinsify this. boolean[] a = new boolean[s.laneCount()];
long shifted = bits; for (int i = 0; i < a.length; i++) {
boolean[] a = new boolean[laneCount]; a[i] = ((shifted & 1) != 0);
for (int i = 0; i < a.length; i++) { shifted >>= 1; // replicate sign bit
a[i] = ((shifted & 1) != 0); }
shifted >>= 1; // replicate sign bit return fromValues(s, a);
} });
return fromValues(vspecies, a);
} }
/** /**

View File

@ -470,12 +470,12 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
public static $abstractvectortype$ zero(VectorSpecies<$Boxtype$> species) { public static $abstractvectortype$ zero(VectorSpecies<$Boxtype$> species) {
$Type$Species vsp = ($Type$Species) species; $Type$Species vsp = ($Type$Species) species;
#if[FP] #if[FP]
return VectorSupport.broadcastCoerced(vsp.vectorType(), $type$.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), $type$.class, species.length(),
toBits(0.0f), vsp, toBits(0.0f), MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
#else[FP] #else[FP]
return VectorSupport.broadcastCoerced(vsp.vectorType(), $type$.class, species.length(), return VectorSupport.fromBitsCoerced(vsp.vectorType(), $type$.class, species.length(),
0, vsp, 0, MODE_BROADCAST, vsp,
((bits_, s_) -> s_.rvOp(i -> bits_))); ((bits_, s_) -> s_.rvOp(i -> bits_)));
#end[FP] #end[FP]
} }
@ -5327,9 +5327,9 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
@ForceInline @ForceInline
final $abstractvectortype$ broadcastBits(long bits) { final $abstractvectortype$ broadcastBits(long bits) {
return ($abstractvectortype$) return ($abstractvectortype$)
VectorSupport.broadcastCoerced( VectorSupport.fromBitsCoerced(
vectorType, $type$.class, laneCount, vectorType, $type$.class, laneCount,
bits, this, bits, MODE_BROADCAST, this,
(bits_, s_) -> s_.rvOp(i -> bits_)); (bits_, s_) -> s_.rvOp(i -> bits_));
} }

View File

@ -1000,9 +1000,9 @@ final class $vectortype$ extends $abstractvectortype$ {
@ForceInline @ForceInline
/*package-private*/ /*package-private*/
static $masktype$ maskAll(boolean bit) { static $masktype$ maskAll(boolean bit) {
return VectorSupport.broadcastCoerced($masktype$.class, $bitstype$.class, VLENGTH, return VectorSupport.fromBitsCoerced($masktype$.class, $bitstype$.class, VLENGTH,
(bit ? -1 : 0), null, (bit ? -1 : 0), MODE_BROADCAST, null,
(v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK));
} }
private static final $masktype$ TRUE_MASK = new $masktype$(true); private static final $masktype$ TRUE_MASK = new $masktype$(true);
private static final $masktype$ FALSE_MASK = new $masktype$(false); private static final $masktype$ FALSE_MASK = new $masktype$(false);

View File

@ -5512,7 +5512,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
static void maskFromToLongByte128VectorTestsSmokeTest(long inputLong) { static void maskFromToLongByte128VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5512,7 +5512,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
static void maskFromToLongByte256VectorTestsSmokeTest(long inputLong) { static void maskFromToLongByte256VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5512,7 +5512,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
static void maskFromToLongByte512VectorTestsSmokeTest(long inputLong) { static void maskFromToLongByte512VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5512,7 +5512,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
static void maskFromToLongByte64VectorTestsSmokeTest(long inputLong) { static void maskFromToLongByte64VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4891,7 +4891,7 @@ public class Double128VectorTests extends AbstractVectorTest {
static void maskFromToLongDouble128VectorTestsSmokeTest(long inputLong) { static void maskFromToLongDouble128VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4891,7 +4891,7 @@ public class Double256VectorTests extends AbstractVectorTest {
static void maskFromToLongDouble256VectorTestsSmokeTest(long inputLong) { static void maskFromToLongDouble256VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4891,7 +4891,7 @@ public class Double512VectorTests extends AbstractVectorTest {
static void maskFromToLongDouble512VectorTestsSmokeTest(long inputLong) { static void maskFromToLongDouble512VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4891,7 +4891,7 @@ public class Double64VectorTests extends AbstractVectorTest {
static void maskFromToLongDouble64VectorTestsSmokeTest(long inputLong) { static void maskFromToLongDouble64VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4869,7 +4869,7 @@ public class Float128VectorTests extends AbstractVectorTest {
static void maskFromToLongFloat128VectorTestsSmokeTest(long inputLong) { static void maskFromToLongFloat128VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4869,7 +4869,7 @@ public class Float256VectorTests extends AbstractVectorTest {
static void maskFromToLongFloat256VectorTestsSmokeTest(long inputLong) { static void maskFromToLongFloat256VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4869,7 +4869,7 @@ public class Float512VectorTests extends AbstractVectorTest {
static void maskFromToLongFloat512VectorTestsSmokeTest(long inputLong) { static void maskFromToLongFloat512VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -4869,7 +4869,7 @@ public class Float64VectorTests extends AbstractVectorTest {
static void maskFromToLongFloat64VectorTestsSmokeTest(long inputLong) { static void maskFromToLongFloat64VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5466,7 +5466,7 @@ public class Int128VectorTests extends AbstractVectorTest {
static void maskFromToLongInt128VectorTestsSmokeTest(long inputLong) { static void maskFromToLongInt128VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5466,7 +5466,7 @@ public class Int256VectorTests extends AbstractVectorTest {
static void maskFromToLongInt256VectorTestsSmokeTest(long inputLong) { static void maskFromToLongInt256VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5466,7 +5466,7 @@ public class Int512VectorTests extends AbstractVectorTest {
static void maskFromToLongInt512VectorTestsSmokeTest(long inputLong) { static void maskFromToLongInt512VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5466,7 +5466,7 @@ public class Int64VectorTests extends AbstractVectorTest {
static void maskFromToLongInt64VectorTestsSmokeTest(long inputLong) { static void maskFromToLongInt64VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5350,7 +5350,7 @@ public class Long128VectorTests extends AbstractVectorTest {
static void maskFromToLongLong128VectorTestsSmokeTest(long inputLong) { static void maskFromToLongLong128VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5350,7 +5350,7 @@ public class Long256VectorTests extends AbstractVectorTest {
static void maskFromToLongLong256VectorTestsSmokeTest(long inputLong) { static void maskFromToLongLong256VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5350,7 +5350,7 @@ public class Long512VectorTests extends AbstractVectorTest {
static void maskFromToLongLong512VectorTestsSmokeTest(long inputLong) { static void maskFromToLongLong512VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5350,7 +5350,7 @@ public class Long64VectorTests extends AbstractVectorTest {
static void maskFromToLongLong64VectorTestsSmokeTest(long inputLong) { static void maskFromToLongLong64VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5491,7 +5491,7 @@ public class Short128VectorTests extends AbstractVectorTest {
static void maskFromToLongShort128VectorTestsSmokeTest(long inputLong) { static void maskFromToLongShort128VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5491,7 +5491,7 @@ public class Short256VectorTests extends AbstractVectorTest {
static void maskFromToLongShort256VectorTestsSmokeTest(long inputLong) { static void maskFromToLongShort256VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5491,7 +5491,7 @@ public class Short512VectorTests extends AbstractVectorTest {
static void maskFromToLongShort512VectorTestsSmokeTest(long inputLong) { static void maskFromToLongShort512VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -5491,7 +5491,7 @@ public class Short64VectorTests extends AbstractVectorTest {
static void maskFromToLongShort64VectorTestsSmokeTest(long inputLong) { static void maskFromToLongShort64VectorTestsSmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
@DataProvider @DataProvider

View File

@ -499,7 +499,7 @@
static void maskFromToLong$vectorteststype$SmokeTest(long inputLong) { static void maskFromToLong$vectorteststype$SmokeTest(long inputLong) {
var vmask = VectorMask.fromLong(SPECIES, inputLong); var vmask = VectorMask.fromLong(SPECIES, inputLong);
long outputLong = vmask.toLong(); long outputLong = vmask.toLong();
Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1)); Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
} }
#end[!MaxBit] #end[!MaxBit]

View File

@ -0,0 +1,138 @@
//
// Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License version 2 only, as
// published by the Free Software Foundation.
//
// This code is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// version 2 for more details (a copy is included in the LICENSE file that
// accompanied this code).
//
// You should have received a copy of the GNU General Public License version
// 2 along with this work; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
// or visit www.oracle.com if you need additional information or have any
// questions.
//
//
package org.openjdk.bench.jdk.incubator.vector;
import jdk.incubator.vector.*;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread)
@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
public class MaskFromLongBenchmark {
static long val = 0;
@Setup(Level.Invocation)
public void BmSetup() {
val++;
}
@Benchmark
public int microMaskFromLong_Byte64() {
VectorMask mask = VectorMask.fromLong(ByteVector.SPECIES_64, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Byte128() {
VectorMask mask = VectorMask.fromLong(ByteVector.SPECIES_128, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Byte256() {
VectorMask mask = VectorMask.fromLong(ByteVector.SPECIES_256, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Byte512() {
VectorMask mask = VectorMask.fromLong(ByteVector.SPECIES_512, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Short64() {
VectorMask mask = VectorMask.fromLong(ShortVector.SPECIES_64, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Short128() {
VectorMask mask = VectorMask.fromLong(ShortVector.SPECIES_128, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Short256() {
VectorMask mask = VectorMask.fromLong(ShortVector.SPECIES_256, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Short512() {
VectorMask mask = VectorMask.fromLong(ShortVector.SPECIES_512, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Integer64() {
VectorMask mask = VectorMask.fromLong(IntVector.SPECIES_64, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Integer128() {
VectorMask mask = VectorMask.fromLong(IntVector.SPECIES_128, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Integer256() {
VectorMask mask = VectorMask.fromLong(IntVector.SPECIES_256, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Integer512() {
VectorMask mask = VectorMask.fromLong(IntVector.SPECIES_512, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Long64() {
VectorMask mask = VectorMask.fromLong(LongVector.SPECIES_64, val);
return mask.laneIsSet(0) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Long128() {
VectorMask mask = VectorMask.fromLong(LongVector.SPECIES_128, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Long256() {
VectorMask mask = VectorMask.fromLong(LongVector.SPECIES_256, val);
return mask.laneIsSet(1) ? 1 : 0;
}
@Benchmark
public int microMaskFromLong_Long512() {
VectorMask mask = VectorMask.fromLong(LongVector.SPECIES_512, val);
return mask.laneIsSet(1) ? 1 : 0;
}
}