8266317: Vector API enhancements

Co-authored-by: Paul Sandoz <psandoz@openjdk.org>
Co-authored-by: Sandhya Viswanathan <sviswanathan@openjdk.org>
Reviewed-by: jbhateja, vlivanov
This commit is contained in:
Paul Sandoz 2021-06-03 15:16:58 +00:00
parent eb385c0de2
commit 5982cfc856
121 changed files with 9631 additions and 736 deletions

View file

@ -138,6 +138,11 @@
return false; return false;
} }
// Does the CPU supports vector unsigned comparison instructions?
static constexpr bool supports_vector_comparison_unsigned(int vlen, BasicType bt) {
return false;
}
// Some microarchitectures have mask registers used on vectors // Some microarchitectures have mask registers used on vectors
static const bool has_predicated_vectors(void) { static const bool has_predicated_vectors(void) {
return UseSVE > 0; return UseSVE > 0;

View file

@ -131,6 +131,11 @@
return false; // not supported return false; // not supported
} }
// Does the CPU supports vector unsigned comparison instructions?
static constexpr bool supports_vector_comparison_unsigned(int vlen, BasicType bt) {
return false;
}
// Some microarchitectures have mask registers used on vectors // Some microarchitectures have mask registers used on vectors
static constexpr bool has_predicated_vectors(void) { static constexpr bool has_predicated_vectors(void) {
return false; return false;

View file

@ -138,6 +138,11 @@
return false; return false;
} }
// Does the CPU supports vector unsigned comparison instructions?
static constexpr bool supports_vector_comparison_unsigned(int vlen, BasicType bt) {
return false;
}
// Some microarchitectures have mask registers used on vectors // Some microarchitectures have mask registers used on vectors
static constexpr bool has_predicated_vectors(void) { static constexpr bool has_predicated_vectors(void) {
return false; return false;

View file

@ -128,6 +128,11 @@
return false; return false;
} }
// Does the CPU supports vector unsigned comparison instructions?
static constexpr bool supports_vector_comparison_unsigned(int vlen, BasicType bt) {
return false;
}
// Some microarchitectures have mask registers used on vectors // Some microarchitectures have mask registers used on vectors
static constexpr bool has_predicated_vectors(void) { static constexpr bool has_predicated_vectors(void) {
return false; return false;

View file

@ -3916,16 +3916,6 @@ void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, Compa
emit_int24(0x3E, (0xC0 | encode), vcc); emit_int24(0x3E, (0xC0 | encode), vcc);
} }
void Assembler::evpcmpuw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) {
assert(VM_Version::supports_avx512vlbw(), "");
InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true);
attributes.reset_is_clear_context();
attributes.set_embedded_opmask_register_specifier(mask);
attributes.set_is_evex_instruction();
int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int24(0x3E, (0xC0 | encode), vcc);
}
void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len) { void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len) {
assert(VM_Version::supports_avx512vlbw(), ""); assert(VM_Version::supports_avx512vlbw(), "");
InstructionMark im(this); InstructionMark im(this);
@ -9163,7 +9153,7 @@ void Assembler::vpcmpgtq(XMMRegister dst, XMMRegister nds, XMMRegister src, int
} }
void Assembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void Assembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
// Encoding: EVEX.NDS.XXX.66.0F3A.W0 1F /r ib // Encoding: EVEX.NDS.XXX.66.0F3A.W0 1F /r ib
@ -9172,11 +9162,12 @@ void Assembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegi
attributes.set_embedded_opmask_register_specifier(mask); attributes.set_embedded_opmask_register_specifier(mask);
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int24(0x1F, (0xC0 | encode), comparison); int opcode = is_signed ? 0x1F : 0x1E;
emit_int24(opcode, (0xC0 | encode), comparison);
} }
void Assembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void Assembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
// Encoding: EVEX.NDS.XXX.66.0F3A.W0 1F /r ib // Encoding: EVEX.NDS.XXX.66.0F3A.W0 1F /r ib
@ -9188,13 +9179,14 @@ void Assembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, Address
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int dst_enc = kdst->encoding(); int dst_enc = kdst->encoding();
vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int8((unsigned char)0x1F); int opcode = is_signed ? 0x1F : 0x1E;
emit_int8((unsigned char)opcode);
emit_operand(as_Register(dst_enc), src); emit_operand(as_Register(dst_enc), src);
emit_int8((unsigned char)comparison); emit_int8((unsigned char)comparison);
} }
void Assembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void Assembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
// Encoding: EVEX.NDS.XXX.66.0F3A.W1 1F /r ib // Encoding: EVEX.NDS.XXX.66.0F3A.W1 1F /r ib
@ -9203,11 +9195,12 @@ void Assembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegi
attributes.set_embedded_opmask_register_specifier(mask); attributes.set_embedded_opmask_register_specifier(mask);
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int24(0x1F, (0xC0 | encode), comparison); int opcode = is_signed ? 0x1F : 0x1E;
emit_int24(opcode, (0xC0 | encode), comparison);
} }
void Assembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void Assembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
// Encoding: EVEX.NDS.XXX.66.0F3A.W1 1F /r ib // Encoding: EVEX.NDS.XXX.66.0F3A.W1 1F /r ib
@ -9219,13 +9212,14 @@ void Assembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, Address
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int dst_enc = kdst->encoding(); int dst_enc = kdst->encoding();
vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int8((unsigned char)0x1F); int opcode = is_signed ? 0x1F : 0x1E;
emit_int8((unsigned char)opcode);
emit_operand(as_Register(dst_enc), src); emit_operand(as_Register(dst_enc), src);
emit_int8((unsigned char)comparison); emit_int8((unsigned char)comparison);
} }
void Assembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void Assembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(VM_Version::supports_avx512bw(), ""); assert(VM_Version::supports_avx512bw(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
@ -9235,11 +9229,12 @@ void Assembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegi
attributes.set_embedded_opmask_register_specifier(mask); attributes.set_embedded_opmask_register_specifier(mask);
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int24(0x3F, (0xC0 | encode), comparison); int opcode = is_signed ? 0x3F : 0x3E;
emit_int24(opcode, (0xC0 | encode), comparison);
} }
void Assembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void Assembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(VM_Version::supports_avx512bw(), ""); assert(VM_Version::supports_avx512bw(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
@ -9252,13 +9247,14 @@ void Assembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, Address
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int dst_enc = kdst->encoding(); int dst_enc = kdst->encoding();
vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int8((unsigned char)0x3F); int opcode = is_signed ? 0x3F : 0x3E;
emit_int8((unsigned char)opcode);
emit_operand(as_Register(dst_enc), src); emit_operand(as_Register(dst_enc), src);
emit_int8((unsigned char)comparison); emit_int8((unsigned char)comparison);
} }
void Assembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void Assembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(VM_Version::supports_avx512bw(), ""); assert(VM_Version::supports_avx512bw(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
@ -9268,11 +9264,12 @@ void Assembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegi
attributes.set_embedded_opmask_register_specifier(mask); attributes.set_embedded_opmask_register_specifier(mask);
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int24(0x3F, (0xC0 | encode), comparison); int opcode = is_signed ? 0x3F : 0x3E;
emit_int24(opcode, (0xC0 | encode), comparison);
} }
void Assembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void Assembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len) { int comparison, bool is_signed, int vector_len) {
assert(VM_Version::supports_evex(), ""); assert(VM_Version::supports_evex(), "");
assert(VM_Version::supports_avx512bw(), ""); assert(VM_Version::supports_avx512bw(), "");
assert(comparison >= Assembler::eq && comparison <= Assembler::_true, ""); assert(comparison >= Assembler::eq && comparison <= Assembler::_true, "");
@ -9285,7 +9282,8 @@ void Assembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, Address
attributes.reset_is_clear_context(); attributes.reset_is_clear_context();
int dst_enc = kdst->encoding(); int dst_enc = kdst->encoding();
vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes);
emit_int8((unsigned char)0x3F); int opcode = is_signed ? 0x3F : 0x3E;
emit_int8((unsigned char)opcode);
emit_operand(as_Register(dst_enc), src); emit_operand(as_Register(dst_enc), src);
emit_int8((unsigned char)comparison); emit_int8((unsigned char)comparison);
} }

View file

@ -1721,7 +1721,6 @@ private:
void evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len); void evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len);
void evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len); void evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len);
void evpcmpuw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, ComparisonPredicate of, int vector_len);
void evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len); void evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len);
void pcmpeqw(XMMRegister dst, XMMRegister src); void pcmpeqw(XMMRegister dst, XMMRegister src);
@ -2495,27 +2494,27 @@ private:
// Vector integer compares // Vector integer compares
void vpcmpgtd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpcmpgtd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len);
void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
// Vector long compares // Vector long compares
void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
// Vector byte compares // Vector byte compares
void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
// Vector short compares // Vector short compares
void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, Address src, void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, Address src,
int comparison, int vector_len); int comparison, bool is_signed, int vector_len);
void evpmovb2m(KRegister dst, XMMRegister src, int vector_len); void evpmovb2m(KRegister dst, XMMRegister src, int vector_len);

View file

@ -2143,18 +2143,18 @@ void C2_MacroAssembler::get_elem(BasicType typ, XMMRegister dst, XMMRegister src
void C2_MacroAssembler::evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask, XMMRegister src1, AddressLiteral adr, int comparison, int vector_len, Register scratch) { void C2_MacroAssembler::evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask, XMMRegister src1, AddressLiteral adr, int comparison, int vector_len, Register scratch) {
switch(typ) { switch(typ) {
case T_BYTE: case T_BYTE:
evpcmpb(kdmask, ksmask, src1, adr, comparison, vector_len, scratch); evpcmpb(kdmask, ksmask, src1, adr, comparison, /*signed*/ true, vector_len, scratch);
break; break;
case T_SHORT: case T_SHORT:
evpcmpw(kdmask, ksmask, src1, adr, comparison, vector_len, scratch); evpcmpw(kdmask, ksmask, src1, adr, comparison, /*signed*/ true, vector_len, scratch);
break; break;
case T_INT: case T_INT:
case T_FLOAT: case T_FLOAT:
evpcmpd(kdmask, ksmask, src1, adr, comparison, vector_len, scratch); evpcmpd(kdmask, ksmask, src1, adr, comparison, /*signed*/ true, vector_len, scratch);
break; break;
case T_LONG: case T_LONG:
case T_DOUBLE: case T_DOUBLE:
evpcmpq(kdmask, ksmask, src1, adr, comparison, vector_len, scratch); evpcmpq(kdmask, ksmask, src1, adr, comparison, /*signed*/ true, vector_len, scratch);
break; break;
default: default:
assert(false,"Should not reach here."); assert(false,"Should not reach here.");
@ -2162,6 +2162,84 @@ void C2_MacroAssembler::evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask
} }
} }
void C2_MacroAssembler::vpcmpu(BasicType typ, XMMRegister dst, XMMRegister src1, XMMRegister src2, ComparisonPredicate comparison,
int vlen_in_bytes, XMMRegister vtmp1, XMMRegister vtmp2, Register scratch) {
int vlen_enc = vector_length_encoding(vlen_in_bytes*2);
switch (typ) {
case T_BYTE:
vpmovzxbw(vtmp1, src1, vlen_enc);
vpmovzxbw(vtmp2, src2, vlen_enc);
vpcmpCCW(dst, vtmp1, vtmp2, comparison, Assembler::W, vlen_enc, scratch);
vpacksswb(dst, dst, dst, vlen_enc);
break;
case T_SHORT:
vpmovzxwd(vtmp1, src1, vlen_enc);
vpmovzxwd(vtmp2, src2, vlen_enc);
vpcmpCCW(dst, vtmp1, vtmp2, comparison, Assembler::D, vlen_enc, scratch);
vpackssdw(dst, dst, dst, vlen_enc);
break;
case T_INT:
vpmovzxdq(vtmp1, src1, vlen_enc);
vpmovzxdq(vtmp2, src2, vlen_enc);
vpcmpCCW(dst, vtmp1, vtmp2, comparison, Assembler::Q, vlen_enc, scratch);
vpermilps(dst, dst, 8, vlen_enc);
break;
default:
assert(false, "Should not reach here");
}
if (vlen_in_bytes == 16) {
vpermpd(dst, dst, 0x8, vlen_enc);
}
}
void C2_MacroAssembler::vpcmpu32(BasicType typ, XMMRegister dst, XMMRegister src1, XMMRegister src2, ComparisonPredicate comparison, int vlen_in_bytes,
XMMRegister vtmp1, XMMRegister vtmp2, XMMRegister vtmp3, Register scratch) {
int vlen_enc = vector_length_encoding(vlen_in_bytes);
switch (typ) {
case T_BYTE:
vpmovzxbw(vtmp1, src1, vlen_enc);
vpmovzxbw(vtmp2, src2, vlen_enc);
vpcmpCCW(dst, vtmp1, vtmp2, comparison, Assembler::W, vlen_enc, scratch);
vextracti128(vtmp1, src1, 1);
vextracti128(vtmp2, src2, 1);
vpmovzxbw(vtmp1, vtmp1, vlen_enc);
vpmovzxbw(vtmp2, vtmp2, vlen_enc);
vpcmpCCW(vtmp3, vtmp1, vtmp2, comparison, Assembler::W, vlen_enc, scratch);
vpacksswb(dst, dst, vtmp3, vlen_enc);
vpermpd(dst, dst, 0xd8, vlen_enc);
break;
case T_SHORT:
vpmovzxwd(vtmp1, src1, vlen_enc);
vpmovzxwd(vtmp2, src2, vlen_enc);
vpcmpCCW(dst, vtmp1, vtmp2, comparison, Assembler::D, vlen_enc, scratch);
vextracti128(vtmp1, src1, 1);
vextracti128(vtmp2, src2, 1);
vpmovzxwd(vtmp1, vtmp1, vlen_enc);
vpmovzxwd(vtmp2, vtmp2, vlen_enc);
vpcmpCCW(vtmp3, vtmp1, vtmp2, comparison, Assembler::D, vlen_enc, scratch);
vpackssdw(dst, dst, vtmp3, vlen_enc);
vpermpd(dst, dst, 0xd8, vlen_enc);
break;
case T_INT:
vpmovzxdq(vtmp1, src1, vlen_enc);
vpmovzxdq(vtmp2, src2, vlen_enc);
vpcmpCCW(dst, vtmp1, vtmp2, comparison, Assembler::Q, vlen_enc, scratch);
vpshufd(dst, dst, 8, vlen_enc);
vpermq(dst, dst, 8, vlen_enc);
vextracti128(vtmp1, src1, 1);
vextracti128(vtmp2, src2, 1);
vpmovzxdq(vtmp1, vtmp1, vlen_enc);
vpmovzxdq(vtmp2, vtmp2, vlen_enc);
vpcmpCCW(vtmp3, vtmp1, vtmp2, comparison, Assembler::Q, vlen_enc, scratch);
vpshufd(vtmp3, vtmp3, 8, vlen_enc);
vpermq(vtmp3, vtmp3, 0x80, vlen_enc);
vpblendd(dst, dst, vtmp3, 0xf0, vlen_enc);
break;
default:
assert(false, "Should not reach here");
}
}
void C2_MacroAssembler::evpblend(BasicType typ, XMMRegister dst, KRegister kmask, XMMRegister src1, XMMRegister src2, bool merge, int vector_len) { void C2_MacroAssembler::evpblend(BasicType typ, XMMRegister dst, KRegister kmask, XMMRegister src1, XMMRegister src2, bool merge, int vector_len) {
switch(typ) { switch(typ) {
case T_BYTE: case T_BYTE:

View file

@ -144,6 +144,12 @@ public:
void load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt); void load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt);
void load_iota_indices(XMMRegister dst, Register scratch, int vlen_in_bytes); void load_iota_indices(XMMRegister dst, Register scratch, int vlen_in_bytes);
// vector compare
void vpcmpu(BasicType typ, XMMRegister dst, XMMRegister src1, XMMRegister src2, ComparisonPredicate comparison, int vlen_in_bytes,
XMMRegister vtmp1, XMMRegister vtmp2, Register scratch);
void vpcmpu32(BasicType typ, XMMRegister dst, XMMRegister src1, XMMRegister src2, ComparisonPredicate comparison, int vlen_in_bytes,
XMMRegister vtmp1, XMMRegister vtmp2, XMMRegister vtmp3, Register scratch);
// Reductions for vectors of bytes, shorts, ints, longs, floats, and doubles. // Reductions for vectors of bytes, shorts, ints, longs, floats, and doubles.
// dst = src1 reduce(op, src2) using vtmp as temps // dst = src1 reduce(op, src2) using vtmp as temps

View file

@ -3345,42 +3345,42 @@ void MacroAssembler::evpcmpeqd(KRegister kdst, KRegister mask, XMMRegister nds,
} }
void MacroAssembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void MacroAssembler::evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg) { int comparison, bool is_signed, int vector_len, Register scratch_reg) {
if (reachable(src)) { if (reachable(src)) {
Assembler::evpcmpd(kdst, mask, nds, as_Address(src), comparison, vector_len); Assembler::evpcmpd(kdst, mask, nds, as_Address(src), comparison, is_signed, vector_len);
} else { } else {
lea(scratch_reg, src); lea(scratch_reg, src);
Assembler::evpcmpd(kdst, mask, nds, Address(scratch_reg, 0), comparison, vector_len); Assembler::evpcmpd(kdst, mask, nds, Address(scratch_reg, 0), comparison, is_signed, vector_len);
} }
} }
void MacroAssembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void MacroAssembler::evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg) { int comparison, bool is_signed, int vector_len, Register scratch_reg) {
if (reachable(src)) { if (reachable(src)) {
Assembler::evpcmpq(kdst, mask, nds, as_Address(src), comparison, vector_len); Assembler::evpcmpq(kdst, mask, nds, as_Address(src), comparison, is_signed, vector_len);
} else { } else {
lea(scratch_reg, src); lea(scratch_reg, src);
Assembler::evpcmpq(kdst, mask, nds, Address(scratch_reg, 0), comparison, vector_len); Assembler::evpcmpq(kdst, mask, nds, Address(scratch_reg, 0), comparison, is_signed, vector_len);
} }
} }
void MacroAssembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void MacroAssembler::evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg) { int comparison, bool is_signed, int vector_len, Register scratch_reg) {
if (reachable(src)) { if (reachable(src)) {
Assembler::evpcmpb(kdst, mask, nds, as_Address(src), comparison, vector_len); Assembler::evpcmpb(kdst, mask, nds, as_Address(src), comparison, is_signed, vector_len);
} else { } else {
lea(scratch_reg, src); lea(scratch_reg, src);
Assembler::evpcmpb(kdst, mask, nds, Address(scratch_reg, 0), comparison, vector_len); Assembler::evpcmpb(kdst, mask, nds, Address(scratch_reg, 0), comparison, is_signed, vector_len);
} }
} }
void MacroAssembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void MacroAssembler::evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg) { int comparison, bool is_signed, int vector_len, Register scratch_reg) {
if (reachable(src)) { if (reachable(src)) {
Assembler::evpcmpw(kdst, mask, nds, as_Address(src), comparison, vector_len); Assembler::evpcmpw(kdst, mask, nds, as_Address(src), comparison, is_signed, vector_len);
} else { } else {
lea(scratch_reg, src); lea(scratch_reg, src);
Assembler::evpcmpw(kdst, mask, nds, Address(scratch_reg, 0), comparison, vector_len); Assembler::evpcmpw(kdst, mask, nds, Address(scratch_reg, 0), comparison, is_signed, vector_len);
} }
} }
@ -8061,7 +8061,7 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le
kmovdl(mask2, result); kmovdl(mask2, result);
evmovdquw(tmp1Reg, mask2, Address(src, 0), /*merge*/ false, Assembler::AVX_512bit); evmovdquw(tmp1Reg, mask2, Address(src, 0), /*merge*/ false, Assembler::AVX_512bit);
evpcmpuw(mask1, mask2, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit); evpcmpw(mask1, mask2, tmp1Reg, tmp2Reg, Assembler::le, /*signed*/ false, Assembler::AVX_512bit);
ktestd(mask1, mask2); ktestd(mask1, mask2);
jcc(Assembler::carryClear, return_zero); jcc(Assembler::carryClear, return_zero);
@ -8111,7 +8111,7 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le
kmovdl(mask2, result); kmovdl(mask2, result);
evmovdquw(tmp1Reg, mask2, Address(src, 0), /*merge*/ false, Assembler::AVX_512bit); evmovdquw(tmp1Reg, mask2, Address(src, 0), /*merge*/ false, Assembler::AVX_512bit);
evpcmpuw(mask1, mask2, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit); evpcmpw(mask1, mask2, tmp1Reg, tmp2Reg, Assembler::le, /*signed*/ false, Assembler::AVX_512bit);
ktestd(mask1, mask2); ktestd(mask1, mask2);
jcc(Assembler::carryClear, return_zero); jcc(Assembler::carryClear, return_zero);

View file

@ -1297,21 +1297,21 @@ public:
// Vector compares // Vector compares
void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { Assembler::evpcmpd(kdst, mask, nds, src, comparison, vector_len); } int comparison, bool is_signed, int vector_len) { Assembler::evpcmpd(kdst, mask, nds, src, comparison, is_signed, vector_len); }
void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void evpcmpd(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg); int comparison, bool is_signed, int vector_len, Register scratch_reg);
void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { Assembler::evpcmpq(kdst, mask, nds, src, comparison, vector_len); } int comparison, bool is_signed, int vector_len) { Assembler::evpcmpq(kdst, mask, nds, src, comparison, is_signed, vector_len); }
void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void evpcmpq(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg); int comparison, bool is_signed, int vector_len, Register scratch_reg);
void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { Assembler::evpcmpb(kdst, mask, nds, src, comparison, vector_len); } int comparison, bool is_signed, int vector_len) { Assembler::evpcmpb(kdst, mask, nds, src, comparison, is_signed, vector_len); }
void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void evpcmpb(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg); int comparison, bool is_signed, int vector_len, Register scratch_reg);
void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src,
int comparison, int vector_len) { Assembler::evpcmpw(kdst, mask, nds, src, comparison, vector_len); } int comparison, bool is_signed, int vector_len) { Assembler::evpcmpw(kdst, mask, nds, src, comparison, is_signed, vector_len); }
void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src, void evpcmpw(KRegister kdst, KRegister mask, XMMRegister nds, AddressLiteral src,
int comparison, int vector_len, Register scratch_reg); int comparison, bool is_signed, int vector_len, Register scratch_reg);
// Emit comparison instruction for the specified comparison predicate. // Emit comparison instruction for the specified comparison predicate.

View file

@ -158,6 +158,24 @@
return true; return true;
} }
// Does the CPU supports vector unsigned comparison instructions?
static const bool supports_vector_comparison_unsigned(int vlen, BasicType bt) {
int vlen_in_bytes = vlen * type2aelembytes(bt);
if ((UseAVX > 2) && (VM_Version::supports_avx512vl() || vlen_in_bytes == 64))
return true;
else {
// instruction set supports only signed comparison
// so need to zero extend to higher integral type and perform comparison
// cannot cast long to higher integral type
// and on avx1 cannot cast 128 bit integral vectors to higher size
if ((bt != T_LONG) &&
((UseAVX >= 2) || (vlen_in_bytes <= 8)))
return true;
}
return false;
}
// Some microarchitectures have mask registers used on vectors // Some microarchitectures have mask registers used on vectors
static const bool has_predicated_vectors(void) { static const bool has_predicated_vectors(void) {
bool ret_value = false; bool ret_value = false;

View file

@ -1274,6 +1274,10 @@ static inline Assembler::AvxVectorLen vector_length_encoding(const MachNode* use
return vector_length_encoding(def); return vector_length_encoding(def);
} }
static inline bool is_unsigned_booltest_pred(int bt) {
return ((bt & BoolTest::unsigned_compare) == BoolTest::unsigned_compare);
}
class Node::PD { class Node::PD {
public: public:
enum NodeFlags { enum NodeFlags {
@ -2154,12 +2158,22 @@ bool Matcher::pd_clone_address_expressions(AddPNode* m, Matcher::MStack& mstack,
static inline Assembler::ComparisonPredicate booltest_pred_to_comparison_pred(int bt) { static inline Assembler::ComparisonPredicate booltest_pred_to_comparison_pred(int bt) {
switch (bt) { switch (bt) {
case BoolTest::eq: return Assembler::eq; case BoolTest::eq:
case BoolTest::ne: return Assembler::neq; return Assembler::eq;
case BoolTest::le: return Assembler::le; case BoolTest::ne:
case BoolTest::ge: return Assembler::nlt; return Assembler::neq;
case BoolTest::lt: return Assembler::lt; case BoolTest::le:
case BoolTest::gt: return Assembler::nle; case BoolTest::ule:
return Assembler::le;
case BoolTest::ge:
case BoolTest::uge:
return Assembler::nlt;
case BoolTest::lt:
case BoolTest::ult:
return Assembler::lt;
case BoolTest::gt:
case BoolTest::ugt:
return Assembler::nle;
default : ShouldNotReachHere(); return Assembler::_false; default : ShouldNotReachHere(); return Assembler::_false;
} }
} }
@ -6867,7 +6881,9 @@ instruct evcmpFD(vec dst, vec src1, vec src2, immI8 cond, rRegP scratch, kReg kt
%} %}
instruct vcmp(legVec dst, legVec src1, legVec src2, immI8 cond, rRegP scratch) %{ instruct vcmp(legVec dst, legVec src1, legVec src2, immI8 cond, rRegP scratch) %{
predicate(vector_length_in_bytes(n->in(1)->in(1)) >= 8 && // src1 predicate((UseAVX <= 2 || !VM_Version::supports_avx512vl()) &&
!is_unsigned_booltest_pred(n->in(2)->get_int()) &&
vector_length_in_bytes(n->in(1)->in(1)) >= 8 && // src1
vector_length_in_bytes(n->in(1)->in(1)) <= 32 && // src1 vector_length_in_bytes(n->in(1)->in(1)) <= 32 && // src1
is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1 is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1
match(Set dst (VectorMaskCmp (Binary src1 src2) cond)); match(Set dst (VectorMaskCmp (Binary src1 src2) cond));
@ -6882,43 +6898,82 @@ instruct vcmp(legVec dst, legVec src1, legVec src2, immI8 cond, rRegP scratch) %
ins_pipe( pipe_slow ); ins_pipe( pipe_slow );
%} %}
instruct evcmp(vec dst, vec src1, vec src2, immI8 cond, rRegP scratch, kReg ktmp) %{ instruct vcmpu(legVec dst, legVec src1, legVec src2, immI8 cond, legVec vtmp1, legVec vtmp2, rRegP scratch) %{
predicate(vector_length_in_bytes(n->in(1)->in(1)) == 64 && // src1 predicate((UseAVX == 2 || !VM_Version::supports_avx512vl()) &&
is_unsigned_booltest_pred(n->in(2)->get_int()) &&
vector_length_in_bytes(n->in(1)->in(1)) >= 8 && // src1
vector_length_in_bytes(n->in(1)->in(1)) <= 16 && // src1
is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1 is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1
match(Set dst (VectorMaskCmp (Binary src1 src2) cond)); match(Set dst (VectorMaskCmp (Binary src1 src2) cond));
effect(TEMP vtmp1, TEMP vtmp2, TEMP scratch);
format %{ "vector_compareu $dst,$src1,$src2,$cond\t! using $scratch as TEMP" %}
ins_encode %{
int vlen = vector_length_in_bytes(this, $src1);
Assembler::ComparisonPredicate cmp = booltest_pred_to_comparison_pred($cond$$constant);
BasicType bt = vector_element_basic_type(this, $src1);
__ vpcmpu(bt, $dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, cmp, vlen, $vtmp1$$XMMRegister,
$vtmp2$$XMMRegister, $scratch$$Register);
%}
ins_pipe( pipe_slow );
%}
instruct vcmpu32(legVec dst, legVec src1, legVec src2, immI8 cond, legVec vtmp1, legVec vtmp2, legVec vtmp3, rRegP scratch) %{
predicate((UseAVX == 2 || !VM_Version::supports_avx512vl()) &&
is_unsigned_booltest_pred(n->in(2)->get_int()) &&
vector_length_in_bytes(n->in(1)->in(1)) == 32 && // src1
is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1
match(Set dst (VectorMaskCmp (Binary src1 src2) cond));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2, TEMP vtmp3, TEMP scratch);
format %{ "vector_compareu $dst,$src1,$src2,$cond\t! using $scratch as TEMP" %}
ins_encode %{
int vlen = vector_length_in_bytes(this, $src1);
Assembler::ComparisonPredicate cmp = booltest_pred_to_comparison_pred($cond$$constant);
BasicType bt = vector_element_basic_type(this, $src1);
__ vpcmpu32(bt, $dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, cmp, vlen, $vtmp1$$XMMRegister,
$vtmp2$$XMMRegister, $vtmp3$$XMMRegister, $scratch$$Register);
%}
ins_pipe( pipe_slow );
%}
instruct evcmp(vec dst, vec src1, vec src2, immI8 cond, rRegP scratch, kReg ktmp) %{
predicate(UseAVX > 2 &&
(VM_Version::supports_avx512vl() ||
vector_length_in_bytes(n->in(1)->in(1)) == 64) && // src1
is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1
match(Set dst (VectorMaskCmp (Binary src1 src2) cond));
effect(TEMP scratch, TEMP ktmp); effect(TEMP scratch, TEMP ktmp);
format %{ "vector_compare $dst,$src1,$src2,$cond\t! using $scratch as TEMP" %} format %{ "vector_compare $dst,$src1,$src2,$cond\t! using $scratch as TEMP" %}
ins_encode %{ ins_encode %{
assert(UseAVX > 2, "required"); assert(UseAVX > 2, "required");
int vlen_enc = Assembler::AVX_512bit; int vlen_enc = vector_length_encoding(this, $src1);
Assembler::ComparisonPredicate cmp = booltest_pred_to_comparison_pred($cond$$constant); Assembler::ComparisonPredicate cmp = booltest_pred_to_comparison_pred($cond$$constant);
bool is_unsigned = is_unsigned_booltest_pred($cond$$constant);
KRegister mask = k0; // The comparison itself is not being masked. KRegister mask = k0; // The comparison itself is not being masked.
bool merge = false; bool merge = false;
BasicType src1_elem_bt = vector_element_basic_type(this, $src1); BasicType src1_elem_bt = vector_element_basic_type(this, $src1);
switch (src1_elem_bt) { switch (src1_elem_bt) {
case T_BYTE: { case T_BYTE: {
__ evpcmpb($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, vlen_enc); __ evpcmpb($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, !is_unsigned, vlen_enc);
__ evmovdqub($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register); __ evmovdqub($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register);
break; break;
} }
case T_SHORT: { case T_SHORT: {
__ evpcmpw($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, vlen_enc); __ evpcmpw($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, !is_unsigned, vlen_enc);
__ evmovdquw($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register); __ evmovdquw($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register);
break; break;
} }
case T_INT: { case T_INT: {
__ evpcmpd($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, vlen_enc); __ evpcmpd($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, !is_unsigned, vlen_enc);
__ evmovdqul($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register); __ evmovdqul($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register);
break; break;
} }
case T_LONG: { case T_LONG: {
__ evpcmpq($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, vlen_enc); __ evpcmpq($ktmp$$KRegister, mask, $src1$$XMMRegister, $src2$$XMMRegister, cmp, !is_unsigned, vlen_enc);
__ evmovdquq($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register); __ evmovdquq($dst$$XMMRegister, $ktmp$$KRegister, ExternalAddress(vector_all_bits_set()), merge, vlen_enc, $scratch$$Register);
break; break;
} }
default: assert(false, "%s", type2name(src1_elem_bt)); default: assert(false, "%s", type2name(src1_elem_bt));
} }
%} %}

View file

@ -304,10 +304,15 @@ public:
// Convert condition codes to a boolean test value (0 or -1). // Convert condition codes to a boolean test value (0 or -1).
// We pick the values as 3 bits; the low order 2 bits we compare against the // We pick the values as 3 bits; the low order 2 bits we compare against the
// condition codes, the high bit flips the sense of the result. // condition codes, the high bit flips the sense of the result.
// For vector compares, additionally, the 4th bit indicates if the compare is unsigned
struct BoolTest { struct BoolTest {
enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, never = 8, illegal = 9 }; enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, never = 8, illegal = 9,
// The following values are used with vector compares
// A BoolTest value should not be constructed for such values
unsigned_compare = 16,
ule = unsigned_compare | le, uge = unsigned_compare | ge, ult = unsigned_compare | lt, ugt = unsigned_compare | gt };
mask _test; mask _test;
BoolTest( mask btm ) : _test(btm) {} BoolTest( mask btm ) : _test(btm) { assert((btm & unsigned_compare) == 0, "unsupported");}
const Type *cc2logical( const Type *CC ) const; const Type *cc2logical( const Type *CC ) const;
// Commute the test. I use a small table lookup. The table is created as // Commute the test. I use a small table lookup. The table is created as
// a simple char array where each element is the ASCII version of a 'mask' // a simple char array where each element is the ASCII version of a 'mask'

View file

@ -605,6 +605,22 @@ bool LibraryCallKit::inline_vector_broadcast_coerced() {
return true; return true;
} }
static bool elem_consistent_with_arr(BasicType elem_bt, const TypeAryPtr* arr_type) {
assert(arr_type != NULL, "unexpected");
BasicType arr_elem_bt = arr_type->elem()->array_element_basic_type();
if (elem_bt == arr_elem_bt) {
return true;
} else if (elem_bt == T_SHORT && arr_elem_bt == T_CHAR) {
// Load/store of short vector from/to char[] is supported
return true;
} else if (elem_bt == T_BYTE && arr_elem_bt == T_BOOLEAN) {
// Load/store of byte vector from/to boolean[] is supported
return true;
} else {
return false;
}
}
// <C, V extends Vector<?,?>> // <C, V extends Vector<?,?>>
// V load(Class<?> vectorClass, Class<?> elementType, int vlen, // V load(Class<?> vectorClass, Class<?> elementType, int vlen,
// Object base, long offset, // Object base, long offset,
@ -682,7 +698,12 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) {
bool using_byte_array = arr_type != NULL && arr_type->elem()->array_element_basic_type() == T_BYTE && elem_bt != T_BYTE; bool using_byte_array = arr_type != NULL && arr_type->elem()->array_element_basic_type() == T_BYTE && elem_bt != T_BYTE;
// Handle loading masks. // Handle loading masks.
// If there is no consistency between array and vector element types, it must be special byte array case or loading masks // If there is no consistency between array and vector element types, it must be special byte array case or loading masks
if (arr_type != NULL && !using_byte_array && elem_bt != arr_type->elem()->array_element_basic_type() && !is_mask) { if (arr_type != NULL && !using_byte_array && !is_mask && !elem_consistent_with_arr(elem_bt, arr_type)) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: arity=%d op=%s vlen=%d etype=%s atype=%s ismask=no",
is_store, is_store ? "store" : "load",
num_elem, type2name(elem_bt), type2name(arr_type->elem()->array_element_basic_type()));
}
set_map(old_map); set_map(old_map);
set_sp(old_sp); set_sp(old_sp);
return false; return false;
@ -865,7 +886,12 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) {
const TypeAryPtr* arr_type = addr_type->isa_aryptr(); const TypeAryPtr* arr_type = addr_type->isa_aryptr();
// The array must be consistent with vector type // The array must be consistent with vector type
if (arr_type == NULL || (arr_type != NULL && elem_bt != arr_type->elem()->array_element_basic_type())) { if (arr_type == NULL || (arr_type != NULL && !elem_consistent_with_arr(elem_bt, arr_type))) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: arity=%d op=%s vlen=%d etype=%s atype=%s ismask=no",
is_scatter, is_scatter ? "scatter" : "gather",
num_elem, type2name(elem_bt), type2name(arr_type->elem()->array_element_basic_type()));
}
set_map(old_map); set_map(old_map);
set_sp(old_sp); set_sp(old_sp);
return false; return false;
@ -1184,6 +1210,16 @@ bool LibraryCallKit::inline_vector_compare() {
BasicType elem_bt = elem_type->basic_type(); BasicType elem_bt = elem_type->basic_type();
BasicType mask_bt = elem_bt; BasicType mask_bt = elem_bt;
if ((cond->get_con() & BoolTest::unsigned_compare) != 0) {
if (!Matcher::supports_vector_comparison_unsigned(num_elem, elem_bt)) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: unsigned comparison op=comp/%d vlen=%d etype=%s ismask=usestore",
cond->get_con() & (BoolTest::unsigned_compare - 1), num_elem, type2name(elem_bt));
}
return false;
}
}
if (!arch_supports_vector(Op_VectorMaskCmp, num_elem, elem_bt, VecMaskUseStore)) { if (!arch_supports_vector(Op_VectorMaskCmp, num_elem, elem_bt, VecMaskUseStore)) {
if (C->print_intrinsics()) { if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: arity=2 op=comp/%d vlen=%d etype=%s ismask=usestore", tty->print_cr(" ** not supported: arity=2 op=comp/%d vlen=%d etype=%s ismask=usestore",

View file

@ -27,11 +27,7 @@ package jdk.internal.vm.vector;
import jdk.internal.vm.annotation.IntrinsicCandidate; import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.misc.Unsafe; import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.function.*; import java.util.function.*;
public class VectorSupport { public class VectorSupport {
@ -74,15 +70,24 @@ public class VectorSupport {
public static final int VECTOR_OP_MASK_FIRSTTRUE = 20; public static final int VECTOR_OP_MASK_FIRSTTRUE = 20;
public static final int VECTOR_OP_MASK_LASTTRUE = 21; public static final int VECTOR_OP_MASK_LASTTRUE = 21;
// enum BoolTest // See src/hotspot/share/opto/subnode.hpp
public static final int BT_eq = 0; // struct BoolTest, and enclosed enum mask
public static final int BT_ne = 4; public static final int BT_eq = 0; // 0000
public static final int BT_le = 5; public static final int BT_ne = 4; // 0100
public static final int BT_ge = 7; public static final int BT_le = 5; // 0101
public static final int BT_lt = 3; public static final int BT_ge = 7; // 0111
public static final int BT_gt = 1; public static final int BT_lt = 3; // 0011
public static final int BT_overflow = 2; public static final int BT_gt = 1; // 0001
public static final int BT_no_overflow = 6; public static final int BT_overflow = 2; // 0010
public static final int BT_no_overflow = 6; // 0110
// never = 8 1000
// illegal = 9 1001
// Unsigned comparisons apply to BT_le, BT_ge, BT_lt, BT_gt for integral types
public static final int BT_unsigned_compare = 0b10000;
public static final int BT_ule = BT_le | BT_unsigned_compare;
public static final int BT_uge = BT_ge | 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;
// BasicType codes, for primitives only: // BasicType codes, for primitives only:
public static final int public static final int

View file

@ -834,6 +834,14 @@ final class Byte128Vector extends ByteVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ByteVector fromBooleanArray0(boolean[] a, int offset) {
return super.fromBooleanArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -866,6 +866,14 @@ final class Byte256Vector extends ByteVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ByteVector fromBooleanArray0(boolean[] a, int offset) {
return super.fromBooleanArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -930,6 +930,14 @@ final class Byte512Vector extends ByteVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ByteVector fromBooleanArray0(boolean[] a, int offset) {
return super.fromBooleanArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -818,6 +818,14 @@ final class Byte64Vector extends ByteVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ByteVector fromBooleanArray0(boolean[] a, int offset) {
return super.fromBooleanArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -804,6 +804,14 @@ final class ByteMaxVector extends ByteVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ByteVector fromBooleanArray0(boolean[] a, int offset) {
return super.fromBooleanArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -379,20 +379,6 @@ public abstract class ByteVector extends AbstractVector<Byte> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, byte a, byte b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract ByteSpecies vspecies(); abstract ByteSpecies vspecies();
@ -1767,17 +1753,20 @@ public abstract class ByteVector extends AbstractVector<Byte> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, byte a, byte b) {
boolean compareWithOp(int cond, byte a, byte b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; case BT_ult -> Byte.compareUnsigned(a, b) < 0;
} case BT_ule -> Byte.compareUnsigned(a, b) <= 0;
throw new AssertionError(); case BT_ugt -> Byte.compareUnsigned(a, b) > 0;
case BT_uge -> Byte.compareUnsigned(a, b) >= 0;
default -> throw new AssertionError();
};
} }
/** /**
@ -2835,6 +2824,165 @@ public abstract class ByteVector extends AbstractVector<Byte> {
return vsp.vOp(m, n -> a[offset + indexMap[mapOffset + n]]); return vsp.vOp(m, n -> a[offset + indexMap[mapOffset + n]]);
} }
/**
* Loads a vector from an array of type {@code boolean[]}
* starting at an offset.
* For each vector lane, where {@code N} is the vector lane index, the
* array element at index {@code offset + N}
* is first converted to a {@code byte} value and then
* placed into the resulting vector at lane index {@code N}.
* <p>
* A {@code boolean} value is converted to a {@code byte} value by applying the
* expression {@code (byte) (b ? 1 : 0)}, where {@code b} is the {@code boolean} value.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public static
ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset) {
offset = checkFromIndexSize(offset, species.length(), a.length);
ByteSpecies vsp = (ByteSpecies) species;
return vsp.dummyVector().fromBooleanArray0(a, offset);
}
/**
* Loads a vector from an array of type {@code boolean[]}
* starting at an offset and using a mask.
* Lanes where the mask is unset are filled with the default
* value of {@code byte} (zero).
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then the array element at
* index {@code offset + N}
* is first converted to a {@code byte} value and then
* placed into the resulting vector at lane index
* {@code N}, otherwise the default element value is placed into the
* resulting vector at lane index {@code N}.
* <p>
* A {@code boolean} value is converted to a {@code byte} value by applying the
* expression {@code (byte) (b ? 1 : 0)}, where {@code b} is the {@code boolean} value.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @param m the mask controlling lane selection
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public static
ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset,
VectorMask<Byte> m) {
ByteSpecies vsp = (ByteSpecies) species;
if (offset >= 0 && offset <= (a.length - species.length())) {
ByteVector zero = vsp.zero();
return zero.blend(zero.fromBooleanArray0(a, offset), m);
}
// FIXME: optimize
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
return vsp.vOp(m, i -> (byte) (a[offset + i] ? 1 : 0));
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code boolean[]},
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane is loaded from the expression
* {@code (byte) (a[f(N)] ? 1 : 0)}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see ByteVector#toIntArray()
*/
@ForceInline
public static
ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
ByteSpecies vsp = (ByteSpecies) species;
return vsp.vOp(n -> (byte) (a[offset + indexMap[mapOffset + n]] ? 1 : 0));
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code boolean[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the lane is set in the mask,
* the lane is loaded from the expression
* {@code (byte) (a[f(N)] ? 1 : 0)}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* Unset lanes in the resulting vector are set to zero.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask controlling lane selection
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see ByteVector#toIntArray()
*/
@ForceInline
public static
ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<Byte> m) {
// FIXME: optimize
ByteSpecies vsp = (ByteSpecies) species;
return vsp.vOp(m, n -> (byte) (a[offset + indexMap[mapOffset + n]] ? 1 : 0));
}
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -2961,7 +3109,7 @@ public abstract class ByteVector extends AbstractVector<Byte> {
} }
/** /**
* Stores this vector into an array of {@code byte} * Stores this vector into an array of type {@code byte[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3077,6 +3225,174 @@ public abstract class ByteVector extends AbstractVector<Byte> {
}); });
} }
/**
* Stores this vector into an array of type {@code boolean[]}
* starting at an offset.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array element {@code a[offset+N]}.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
*
* @param a the array
* @param offset the offset into the array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset) {
offset = checkFromIndexSize(offset, length(), a.length);
ByteSpecies vsp = vspecies();
ByteVector normalized = this.and((byte) 1);
VectorSupport.store(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, booleanArrayAddress(a, offset),
normalized,
a, offset,
(arr, off, v)
-> v.stOp(arr, off,
(arr_, off_, i, e) -> arr_[off_ + i] = (e & 1) != 0));
}
/**
* Stores this vector into an array of type {@code boolean[]}
* starting at offset and using a mask.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array element {@code a[offset+N]}.
* If the mask lane at {@code N} is unset then the corresponding
* array element {@code a[offset+N]} is left unchanged.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
* <p>
* Array range checking is done for lanes where the mask is set.
* Lanes where the mask is unset are not stored and do not need
* to correspond to legitimate elements of {@code a}.
* That is, unset lanes may correspond to array indexes less than
* zero or beyond the end of the array.
*
* @param a the array
* @param offset the offset into the array
* @param m the mask controlling lane storage
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset,
VectorMask<Byte> m) {
if (m.allTrue()) {
intoBooleanArray(a, offset);
} else {
// FIXME: optimize
ByteSpecies vsp = vspecies();
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
stOp(a, offset, m, (arr, off, i, e) -> arr[off+i] = (e & 1) != 0);
}
}
/**
* Scatters this vector into an array of type {@code boolean[]}
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see ByteVector#toIntArray()
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
stOp(a, offset,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (e & 1) != 0;
});
}
/**
* Scatters this vector into an array of type {@code boolean[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see ByteVector#toIntArray()
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<Byte> m) {
// FIXME: optimize
stOp(a, offset, m,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (e & 1) != 0;
});
}
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3183,6 +3499,22 @@ public abstract class ByteVector extends AbstractVector<Byte> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
/*package-private*/
abstract
ByteVector fromBooleanArray0(boolean[] a, int offset);
@ForceInline
final
ByteVector fromBooleanArray0Template(boolean[] a, int offset) {
ByteSpecies vsp = vspecies();
return VectorSupport.load(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, booleanArrayAddress(a, offset),
a, offset, vsp,
(arr, off, s) -> s.ldOp(arr, off,
(arr_, off_, i) -> (byte) (arr_[off_ + i] ? 1 : 0)));
}
@Override @Override
abstract abstract
ByteVector fromByteArray0(byte[] a, int offset); ByteVector fromByteArray0(byte[] a, int offset);
@ -3313,6 +3645,17 @@ public abstract class ByteVector extends AbstractVector<Byte> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
static final int ARRAY_BOOLEAN_SHIFT =
31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
static final long ARRAY_BOOLEAN_BASE =
Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
@ForceInline
static long booleanArrayAddress(boolean[] a, int index) {
return ARRAY_BOOLEAN_BASE + (((long)index) << ARRAY_BOOLEAN_SHIFT);
}
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -802,6 +802,8 @@ final class Double128Vector extends DoubleVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -806,6 +806,8 @@ final class Double256Vector extends DoubleVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -814,6 +814,8 @@ final class Double512Vector extends DoubleVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -800,6 +800,8 @@ final class Double64Vector extends DoubleVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -799,6 +799,8 @@ final class DoubleMaxVector extends DoubleVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -379,20 +379,6 @@ public abstract class DoubleVector extends AbstractVector<Double> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, double a, double b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract DoubleSpecies vspecies(); abstract DoubleSpecies vspecies();
@ -1680,17 +1666,16 @@ public abstract class DoubleVector extends AbstractVector<Double> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, double a, double b) {
boolean compareWithOp(int cond, double a, double b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; default -> throw new AssertionError();
} };
throw new AssertionError();
} }
/** /**
@ -2742,6 +2727,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
} }
} }
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -2874,7 +2861,7 @@ public abstract class DoubleVector extends AbstractVector<Double> {
} }
/** /**
* Stores this vector into an array of {@code double} * Stores this vector into an array of type {@code double[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3031,6 +3018,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
} }
} }
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3137,6 +3126,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
@Override @Override
abstract abstract
DoubleVector fromByteArray0(byte[] a, int offset); DoubleVector fromByteArray0(byte[] a, int offset);
@ -3272,6 +3263,8 @@ public abstract class DoubleVector extends AbstractVector<Double> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -806,6 +806,8 @@ final class Float128Vector extends FloatVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -814,6 +814,8 @@ final class Float256Vector extends FloatVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -830,6 +830,8 @@ final class Float512Vector extends FloatVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -802,6 +802,8 @@ final class Float64Vector extends FloatVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -799,6 +799,8 @@ final class FloatMaxVector extends FloatVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -379,20 +379,6 @@ public abstract class FloatVector extends AbstractVector<Float> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, float a, float b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract FloatSpecies vspecies(); abstract FloatSpecies vspecies();
@ -1692,17 +1678,16 @@ public abstract class FloatVector extends AbstractVector<Float> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, float a, float b) {
boolean compareWithOp(int cond, float a, float b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; default -> throw new AssertionError();
} };
throw new AssertionError();
} }
/** /**
@ -2748,6 +2733,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
} }
} }
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -2880,7 +2867,7 @@ public abstract class FloatVector extends AbstractVector<Float> {
} }
/** /**
* Stores this vector into an array of {@code float} * Stores this vector into an array of type {@code float[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3018,6 +3005,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
} }
} }
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3124,6 +3113,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
@Override @Override
abstract abstract
FloatVector fromByteArray0(byte[] a, int offset); FloatVector fromByteArray0(byte[] a, int offset);
@ -3259,6 +3250,8 @@ public abstract class FloatVector extends AbstractVector<Float> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -810,6 +810,8 @@ final class Int128Vector extends IntVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -818,6 +818,8 @@ final class Int256Vector extends IntVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -834,6 +834,8 @@ final class Int512Vector extends IntVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -806,6 +806,8 @@ final class Int64Vector extends IntVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -815,6 +815,8 @@ final class IntMaxVector extends IntVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -379,20 +379,6 @@ public abstract class IntVector extends AbstractVector<Integer> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, int a, int b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract IntSpecies vspecies(); abstract IntSpecies vspecies();
@ -1766,17 +1752,20 @@ public abstract class IntVector extends AbstractVector<Integer> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, int a, int b) {
boolean compareWithOp(int cond, int a, int b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; case BT_ult -> Integer.compareUnsigned(a, b) < 0;
} case BT_ule -> Integer.compareUnsigned(a, b) <= 0;
throw new AssertionError(); case BT_ugt -> Integer.compareUnsigned(a, b) > 0;
case BT_uge -> Integer.compareUnsigned(a, b) >= 0;
default -> throw new AssertionError();
};
} }
/** /**
@ -2851,6 +2840,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
} }
} }
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -2983,7 +2974,7 @@ public abstract class IntVector extends AbstractVector<Integer> {
} }
/** /**
* Stores this vector into an array of {@code int} * Stores this vector into an array of type {@code int[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3121,6 +3112,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
} }
} }
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3227,6 +3220,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
@Override @Override
abstract abstract
IntVector fromByteArray0(byte[] a, int offset); IntVector fromByteArray0(byte[] a, int offset);
@ -3362,6 +3357,8 @@ public abstract class IntVector extends AbstractVector<Integer> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -796,6 +796,8 @@ final class Long128Vector extends LongVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -800,6 +800,8 @@ final class Long256Vector extends LongVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -808,6 +808,8 @@ final class Long512Vector extends LongVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -794,6 +794,8 @@ final class Long64Vector extends LongVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -794,6 +794,8 @@ final class LongMaxVector extends LongVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -379,20 +379,6 @@ public abstract class LongVector extends AbstractVector<Long> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, long a, long b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract LongSpecies vspecies(); abstract LongSpecies vspecies();
@ -1684,17 +1670,20 @@ public abstract class LongVector extends AbstractVector<Long> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, long a, long b) {
boolean compareWithOp(int cond, long a, long b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; case BT_ult -> Long.compareUnsigned(a, b) < 0;
} case BT_ule -> Long.compareUnsigned(a, b) <= 0;
throw new AssertionError(); case BT_ugt -> Long.compareUnsigned(a, b) > 0;
case BT_uge -> Long.compareUnsigned(a, b) >= 0;
default -> throw new AssertionError();
};
} }
/** /**
@ -2735,6 +2724,8 @@ public abstract class LongVector extends AbstractVector<Long> {
} }
} }
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -2867,7 +2858,7 @@ public abstract class LongVector extends AbstractVector<Long> {
} }
/** /**
* Stores this vector into an array of {@code long} * Stores this vector into an array of type {@code long[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3024,6 +3015,8 @@ public abstract class LongVector extends AbstractVector<Long> {
} }
} }
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3130,6 +3123,8 @@ public abstract class LongVector extends AbstractVector<Long> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
@Override @Override
abstract abstract
LongVector fromByteArray0(byte[] a, int offset); LongVector fromByteArray0(byte[] a, int offset);
@ -3265,6 +3260,8 @@ public abstract class LongVector extends AbstractVector<Long> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -818,6 +818,14 @@ final class Short128Vector extends ShortVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ShortVector fromCharArray0(char[] a, int offset) {
return super.fromCharArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -834,6 +834,14 @@ final class Short256Vector extends ShortVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ShortVector fromCharArray0(char[] a, int offset) {
return super.fromCharArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -866,6 +866,14 @@ final class Short512Vector extends ShortVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ShortVector fromCharArray0(char[] a, int offset) {
return super.fromCharArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -810,6 +810,14 @@ final class Short64Vector extends ShortVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ShortVector fromCharArray0(char[] a, int offset) {
return super.fromCharArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -804,6 +804,14 @@ final class ShortMaxVector extends ShortVector {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
@ForceInline
@Override
final
ShortVector fromCharArray0(char[] a, int offset) {
return super.fromCharArray0Template(a, offset); // specialize
}
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -379,20 +379,6 @@ public abstract class ShortVector extends AbstractVector<Short> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, short a, short b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract ShortSpecies vspecies(); abstract ShortSpecies vspecies();
@ -1767,17 +1753,20 @@ public abstract class ShortVector extends AbstractVector<Short> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, short a, short b) {
boolean compareWithOp(int cond, short a, short b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; case BT_ult -> Short.compareUnsigned(a, b) < 0;
} case BT_ule -> Short.compareUnsigned(a, b) <= 0;
throw new AssertionError(); case BT_ugt -> Short.compareUnsigned(a, b) > 0;
case BT_uge -> Short.compareUnsigned(a, b) >= 0;
default -> throw new AssertionError();
};
} }
/** /**
@ -2835,6 +2824,159 @@ public abstract class ShortVector extends AbstractVector<Short> {
return vsp.vOp(m, n -> a[offset + indexMap[mapOffset + n]]); return vsp.vOp(m, n -> a[offset + indexMap[mapOffset + n]]);
} }
/**
* Loads a vector from an array of type {@code char[]}
* starting at an offset.
* For each vector lane, where {@code N} is the vector lane index, the
* array element at index {@code offset + N}
* is first cast to a {@code short} value and then
* placed into the resulting vector at lane index {@code N}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public static
ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset) {
offset = checkFromIndexSize(offset, species.length(), a.length);
ShortSpecies vsp = (ShortSpecies) species;
return vsp.dummyVector().fromCharArray0(a, offset);
}
/**
* Loads a vector from an array of type {@code char[]}
* starting at an offset and using a mask.
* Lanes where the mask is unset are filled with the default
* value of {@code short} (zero).
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then the array element at
* index {@code offset + N}
* is first cast to a {@code short} value and then
* placed into the resulting vector at lane index
* {@code N}, otherwise the default element value is placed into the
* resulting vector at lane index {@code N}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @param m the mask controlling lane selection
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public static
ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset,
VectorMask<Short> m) {
ShortSpecies vsp = (ShortSpecies) species;
if (offset >= 0 && offset <= (a.length - species.length())) {
ShortVector zero = vsp.zero();
return zero.blend(zero.fromCharArray0(a, offset), m);
}
// FIXME: optimize
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
return vsp.vOp(m, i -> (short) a[offset + i]);
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code char[]},
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane is loaded from the expression
* {@code (short) a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see ShortVector#toIntArray()
*/
@ForceInline
public static
ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
ShortSpecies vsp = (ShortSpecies) species;
return vsp.vOp(n -> (short) a[offset + indexMap[mapOffset + n]]);
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code char[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the lane is set in the mask,
* the lane is loaded from the expression
* {@code (short) a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* Unset lanes in the resulting vector are set to zero.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask controlling lane selection
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see ShortVector#toIntArray()
*/
@ForceInline
public static
ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<Short> m) {
// FIXME: optimize
ShortSpecies vsp = (ShortSpecies) species;
return vsp.vOp(m, n -> (short) a[offset + indexMap[mapOffset + n]]);
}
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -2967,7 +3109,7 @@ public abstract class ShortVector extends AbstractVector<Short> {
} }
/** /**
* Stores this vector into an array of {@code short} * Stores this vector into an array of type {@code short[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3083,6 +3225,161 @@ public abstract class ShortVector extends AbstractVector<Short> {
}); });
} }
/**
* Stores this vector into an array of type {@code char[]}
* starting at an offset.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array element {@code a[offset+N]}.
*
* @param a the array, of type {@code char[]}
* @param offset the offset into the array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset) {
offset = checkFromIndexSize(offset, length(), a.length);
ShortSpecies vsp = vspecies();
VectorSupport.store(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, charArrayAddress(a, offset),
this,
a, offset,
(arr, off, v)
-> v.stOp(arr, off,
(arr_, off_, i, e) -> arr_[off_ + i] = (char) e));
}
/**
* Stores this vector into an array of type {@code char[]}
* starting at offset and using a mask.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array element {@code a[offset+N]}.
* If the mask lane at {@code N} is unset then the corresponding
* array element {@code a[offset+N]} is left unchanged.
* <p>
* Array range checking is done for lanes where the mask is set.
* Lanes where the mask is unset are not stored and do not need
* to correspond to legitimate elements of {@code a}.
* That is, unset lanes may correspond to array indexes less than
* zero or beyond the end of the array.
*
* @param a the array, of type {@code char[]}
* @param offset the offset into the array
* @param m the mask controlling lane storage
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset,
VectorMask<Short> m) {
if (m.allTrue()) {
intoCharArray(a, offset);
} else {
// FIXME: optimize
ShortSpecies vsp = vspecies();
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
stOp(a, offset, m, (arr, off, i, v) -> arr[off+i] = (char) v);
}
}
/**
* Scatters this vector into an array of type {@code char[]}
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see ShortVector#toIntArray()
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
stOp(a, offset,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (char) e;
});
}
/**
* Scatters this vector into an array of type {@code char[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see ShortVector#toIntArray()
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<Short> m) {
// FIXME: optimize
stOp(a, offset, m,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (char) e;
});
}
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3189,6 +3486,22 @@ public abstract class ShortVector extends AbstractVector<Short> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
/*package-private*/
abstract
ShortVector fromCharArray0(char[] a, int offset);
@ForceInline
final
ShortVector fromCharArray0Template(char[] a, int offset) {
ShortSpecies vsp = vspecies();
return VectorSupport.load(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, charArrayAddress(a, offset),
a, offset, vsp,
(arr, off, s) -> s.ldOp(arr, off,
(arr_, off_, i) -> (short) arr_[off_ + i]));
}
@Override @Override
abstract abstract
ShortVector fromByteArray0(byte[] a, int offset); ShortVector fromByteArray0(byte[] a, int offset);
@ -3324,6 +3637,17 @@ public abstract class ShortVector extends AbstractVector<Short> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
static final int ARRAY_CHAR_SHIFT =
31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_CHAR_INDEX_SCALE);
static final long ARRAY_CHAR_BASE =
Unsafe.ARRAY_CHAR_BASE_OFFSET;
@ForceInline
static long charArrayAddress(char[] a, int index) {
return ARRAY_CHAR_BASE + (((long)index) << ARRAY_CHAR_SHIFT);
}
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -240,13 +240,13 @@ import java.util.Arrays;
* each distinct lane of the input vector. If there are additional * each distinct lane of the input vector. If there are additional
* vector arguments of the same type, their lanes are aligned with the * vector arguments of the same type, their lanes are aligned with the
* lanes of the first input vector. (They must all have a common * lanes of the first input vector. (They must all have a common
* {@code VLENGTH}.) The output resulting from a lane-wise operation * {@code VLENGTH}.) For most lane-wise operations, the output resulting
* will have a {@code VLENGTH} which is equal to the {@code VLENGTH} * from a lane-wise operation will have a {@code VLENGTH} which is equal to
* of the input(s) to the operation. Thus, lane-wise operations are * the {@code VLENGTH} of the input(s) to the operation. Thus, such lane-wise
* <em>length-invariant</em>, in their basic definitions. * operations are <em>length-invariant</em>, in their basic definitions.
* *
* <p> The principle of length-invariance is combined with another * <p> The principle of length-invariance is combined with another
* basic principle, that lane-wise operations are always * basic principle, that most length-invariant lane-wise operations are also
* <em>shape-invariant</em>, meaning that the inputs and the output of * <em>shape-invariant</em>, meaning that the inputs and the output of
* a lane-wise operation will have a common {@code VSHAPE}. When the * a lane-wise operation will have a common {@code VSHAPE}. When the
* principles conflict, because a logical result (with an invariant * principles conflict, because a logical result (with an invariant
@ -799,7 +799,8 @@ import java.util.Arrays;
* approach to the design of such <em>resizing</em> vector operations. * approach to the design of such <em>resizing</em> vector operations.
* *
* <p> As a basic principle, lane-wise operations are * <p> As a basic principle, lane-wise operations are
* <em>length-invariant</em>. Length-invariance simply means that * <em>length-invariant</em>, unless clearly marked otherwise.
* Length-invariance simply means that
* if {@code VLENGTH} lanes go into an operation, the same number * if {@code VLENGTH} lanes go into an operation, the same number
* of lanes come out, with nothing discarded and no extra padding. * of lanes come out, with nothing discarded and no extra padding.
* *

View file

@ -565,7 +565,26 @@ public abstract class VectorOperators {
public static final Comparison GT = compare("GT", ">", VectorSupport.BT_gt, VO_ALL); public static final Comparison GT = compare("GT", ">", VectorSupport.BT_gt, VO_ALL);
/** Compare {@code a>=b}. */ /** Compare {@code a>=b}. */
public static final Comparison GE = compare("GE", ">=", VectorSupport.BT_ge, VO_ALL); public static final Comparison GE = compare("GE", ">=", VectorSupport.BT_ge, VO_ALL);
// FIXME: add unsigned comparisons /** Unsigned compare {@code a<b}. Integral only.
* @see java.lang.Integer#compareUnsigned
* @see java.lang.Long#compareUnsigned
*/
public static final Comparison UNSIGNED_LT = compare("UNSIGNED_LT", "<", VectorSupport.BT_ult, VO_NOFP);
/** Unsigned compare {@code a<=b}. Integral only.
* @see java.lang.Integer#compareUnsigned
* @see java.lang.Long#compareUnsigned
*/
public static final Comparison UNSIGNED_LE = compare("UNSIGNED_LE", "<=", VectorSupport.BT_ule, VO_NOFP);
/** Unsigned compare {@code a>b}. Integral only.
* @see java.lang.Integer#compareUnsigned
* @see java.lang.Long#compareUnsigned
*/
public static final Comparison UNSIGNED_GT = compare("UNSIGNED_GT", ">", VectorSupport.BT_ugt, VO_NOFP);
/** Unsigned compare {@code a>=b}. Integral only.
* @see java.lang.Integer#compareUnsigned
* @see java.lang.Long#compareUnsigned
*/
public static final Comparison UNSIGNED_GE = compare("UNSIGNED_GE", ">=", VectorSupport.BT_uge, VO_NOFP);
// Conversion operators // Conversion operators

View file

@ -383,20 +383,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
return maskFactory(bits); return maskFactory(bits);
} }
/*package-private*/
@ForceInline
static boolean doBinTest(int cond, $type$ a, $type$ b) {
switch (cond) {
case BT_eq: return a == b;
case BT_ne: return a != b;
case BT_lt: return a < b;
case BT_le: return a <= b;
case BT_gt: return a > b;
case BT_ge: return a >= b;
}
throw new AssertionError(Integer.toHexString(cond));
}
/*package-private*/ /*package-private*/
@Override @Override
abstract $Type$Species vspecies(); abstract $Type$Species vspecies();
@ -2032,17 +2018,22 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
} }
@ForceInline @ForceInline
private static private static boolean compareWithOp(int cond, $type$ a, $type$ b) {
boolean compareWithOp(int cond, $type$ a, $type$ b) { return switch (cond) {
switch (cond) { case BT_eq -> a == b;
case BT_eq: return a == b; case BT_ne -> a != b;
case BT_ne: return a != b; case BT_lt -> a < b;
case BT_lt: return a < b; case BT_le -> a <= b;
case BT_le: return a <= b; case BT_gt -> a > b;
case BT_gt: return a > b; case BT_ge -> a >= b;
case BT_ge: return a >= b; #if[!FP]
} case BT_ult -> $Boxtype$.compareUnsigned(a, b) < 0;
throw new AssertionError(); case BT_ule -> $Boxtype$.compareUnsigned(a, b) <= 0;
case BT_ugt -> $Boxtype$.compareUnsigned(a, b) > 0;
case BT_uge -> $Boxtype$.compareUnsigned(a, b) >= 0;
#end[!FP]
default -> throw new AssertionError();
};
} }
/** /**
@ -3375,6 +3366,320 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
} }
#end[byteOrShort] #end[byteOrShort]
#if[short]
/**
* Loads a vector from an array of type {@code char[]}
* starting at an offset.
* For each vector lane, where {@code N} is the vector lane index, the
* array element at index {@code offset + N}
* is first cast to a {@code short} value and then
* placed into the resulting vector at lane index {@code N}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public static
$abstractvectortype$ fromCharArray(VectorSpecies<$Boxtype$> species,
char[] a, int offset) {
offset = checkFromIndexSize(offset, species.length(), a.length);
$Type$Species vsp = ($Type$Species) species;
return vsp.dummyVector().fromCharArray0(a, offset);
}
/**
* Loads a vector from an array of type {@code char[]}
* starting at an offset and using a mask.
* Lanes where the mask is unset are filled with the default
* value of {@code $type$} ({#if[FP]?positive }zero).
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then the array element at
* index {@code offset + N}
* is first cast to a {@code short} value and then
* placed into the resulting vector at lane index
* {@code N}, otherwise the default element value is placed into the
* resulting vector at lane index {@code N}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @param m the mask controlling lane selection
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public static
$abstractvectortype$ fromCharArray(VectorSpecies<$Boxtype$> species,
char[] a, int offset,
VectorMask<$Boxtype$> m) {
$Type$Species vsp = ($Type$Species) species;
if (offset >= 0 && offset <= (a.length - species.length())) {
$abstractvectortype$ zero = vsp.zero();
return zero.blend(zero.fromCharArray0(a, offset), m);
}
// FIXME: optimize
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
return vsp.vOp(m, i -> (short) a[offset + i]);
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code char[]},
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane is loaded from the expression
* {@code (short) a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public static
$abstractvectortype$ fromCharArray(VectorSpecies<$Boxtype$> species,
char[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
$Type$Species vsp = ($Type$Species) species;
return vsp.vOp(n -> (short) a[offset + indexMap[mapOffset + n]]);
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code char[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the lane is set in the mask,
* the lane is loaded from the expression
* {@code (short) a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* Unset lanes in the resulting vector are set to zero.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask controlling lane selection
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public static
$abstractvectortype$ fromCharArray(VectorSpecies<$Boxtype$> species,
char[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<$Boxtype$> m) {
// FIXME: optimize
$Type$Species vsp = ($Type$Species) species;
return vsp.vOp(m, n -> (short) a[offset + indexMap[mapOffset + n]]);
}
#end[short]
#if[byte]
/**
* Loads a vector from an array of type {@code boolean[]}
* starting at an offset.
* For each vector lane, where {@code N} is the vector lane index, the
* array element at index {@code offset + N}
* is first converted to a {@code byte} value and then
* placed into the resulting vector at lane index {@code N}.
* <p>
* A {@code boolean} value is converted to a {@code byte} value by applying the
* expression {@code (byte) (b ? 1 : 0)}, where {@code b} is the {@code boolean} value.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public static
$abstractvectortype$ fromBooleanArray(VectorSpecies<$Boxtype$> species,
boolean[] a, int offset) {
offset = checkFromIndexSize(offset, species.length(), a.length);
$Type$Species vsp = ($Type$Species) species;
return vsp.dummyVector().fromBooleanArray0(a, offset);
}
/**
* Loads a vector from an array of type {@code boolean[]}
* starting at an offset and using a mask.
* Lanes where the mask is unset are filled with the default
* value of {@code $type$} ({#if[FP]?positive }zero).
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then the array element at
* index {@code offset + N}
* is first converted to a {@code byte} value and then
* placed into the resulting vector at lane index
* {@code N}, otherwise the default element value is placed into the
* resulting vector at lane index {@code N}.
* <p>
* A {@code boolean} value is converted to a {@code byte} value by applying the
* expression {@code (byte) (b ? 1 : 0)}, where {@code b} is the {@code boolean} value.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array
* @param m the mask controlling lane selection
* @return the vector loaded from an array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public static
$abstractvectortype$ fromBooleanArray(VectorSpecies<$Boxtype$> species,
boolean[] a, int offset,
VectorMask<$Boxtype$> m) {
$Type$Species vsp = ($Type$Species) species;
if (offset >= 0 && offset <= (a.length - species.length())) {
$abstractvectortype$ zero = vsp.zero();
return zero.blend(zero.fromBooleanArray0(a, offset), m);
}
// FIXME: optimize
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
return vsp.vOp(m, i -> (byte) (a[offset + i] ? 1 : 0));
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code boolean[]},
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane is loaded from the expression
* {@code (byte) (a[f(N)] ? 1 : 0)}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public static
$abstractvectortype$ fromBooleanArray(VectorSpecies<$Boxtype$> species,
boolean[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
$Type$Species vsp = ($Type$Species) species;
return vsp.vOp(n -> (byte) (a[offset + indexMap[mapOffset + n]] ? 1 : 0));
}
/**
* Gathers a new vector composed of elements from an array of type
* {@code boolean[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the lane is set in the mask,
* the lane is loaded from the expression
* {@code (byte) (a[f(N)] ? 1 : 0)}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* Unset lanes in the resulting vector are set to zero.
*
* @param species species of desired vector
* @param a the array
* @param offset the offset into the array, may be negative if relative
* indexes in the index map compensate to produce a value within the
* array bounds
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask controlling lane selection
* @return the vector loaded from the indexed elements of the array
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public static
$abstractvectortype$ fromBooleanArray(VectorSpecies<$Boxtype$> species,
boolean[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<$Boxtype$> m) {
// FIXME: optimize
$Type$Species vsp = ($Type$Species) species;
return vsp.vOp(m, n -> (byte) (a[offset + indexMap[mapOffset + n]] ? 1 : 0));
}
#end[byte]
/** /**
* Loads a vector from a {@linkplain ByteBuffer byte buffer} * Loads a vector from a {@linkplain ByteBuffer byte buffer}
* starting at an offset into the byte buffer. * starting at an offset into the byte buffer.
@ -3513,7 +3818,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
} }
/** /**
* Stores this vector into an array of {@code $type$} * Stores this vector into an array of type {@code $type$[]}
* starting at offset and using a mask. * starting at offset and using a mask.
* <p> * <p>
* For each vector lane, where {@code N} is the vector lane index, * For each vector lane, where {@code N} is the vector lane index,
@ -3704,6 +4009,331 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
} }
#end[byteOrShort] #end[byteOrShort]
#if[short]
/**
* Stores this vector into an array of type {@code char[]}
* starting at an offset.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array element {@code a[offset+N]}.
*
* @param a the array, of type {@code char[]}
* @param offset the offset into the array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset) {
offset = checkFromIndexSize(offset, length(), a.length);
$Type$Species vsp = vspecies();
VectorSupport.store(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, charArrayAddress(a, offset),
this,
a, offset,
(arr, off, v)
-> v.stOp(arr, off,
(arr_, off_, i, e) -> arr_[off_ + i] = (char) e));
}
/**
* Stores this vector into an array of type {@code char[]}
* starting at offset and using a mask.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array element {@code a[offset+N]}.
* If the mask lane at {@code N} is unset then the corresponding
* array element {@code a[offset+N]} is left unchanged.
* <p>
* Array range checking is done for lanes where the mask is set.
* Lanes where the mask is unset are not stored and do not need
* to correspond to legitimate elements of {@code a}.
* That is, unset lanes may correspond to array indexes less than
* zero or beyond the end of the array.
*
* @param a the array, of type {@code char[]}
* @param offset the offset into the array
* @param m the mask controlling lane storage
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset,
VectorMask<$Boxtype$> m) {
if (m.allTrue()) {
intoCharArray(a, offset);
} else {
// FIXME: optimize
$Type$Species vsp = vspecies();
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
stOp(a, offset, m, (arr, off, i, v) -> arr[off+i] = (char) v);
}
}
/**
* Scatters this vector into an array of type {@code char[]}
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
stOp(a, offset,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (char) e;
});
}
/**
* Scatters this vector into an array of type {@code char[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then
* the lane element at index {@code N}
* is first cast to a {@code char} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public final
void intoCharArray(char[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<$Boxtype$> m) {
// FIXME: optimize
stOp(a, offset, m,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (char) e;
});
}
#end[short]
#if[byte]
/**
* Stores this vector into an array of type {@code boolean[]}
* starting at an offset.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array element {@code a[offset+N]}.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
*
* @param a the array
* @param offset the offset into the array
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset) {
offset = checkFromIndexSize(offset, length(), a.length);
$Type$Species vsp = vspecies();
ByteVector normalized = this.and((byte) 1);
VectorSupport.store(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, booleanArrayAddress(a, offset),
normalized,
a, offset,
(arr, off, v)
-> v.stOp(arr, off,
(arr_, off_, i, e) -> arr_[off_ + i] = (e & 1) != 0));
}
/**
* Stores this vector into an array of type {@code boolean[]}
* starting at offset and using a mask.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array element {@code a[offset+N]}.
* If the mask lane at {@code N} is unset then the corresponding
* array element {@code a[offset+N]} is left unchanged.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
* <p>
* Array range checking is done for lanes where the mask is set.
* Lanes where the mask is unset are not stored and do not need
* to correspond to legitimate elements of {@code a}.
* That is, unset lanes may correspond to array indexes less than
* zero or beyond the end of the array.
*
* @param a the array
* @param offset the offset into the array
* @param m the mask controlling lane storage
* @throws IndexOutOfBoundsException
* if {@code offset+N < 0} or {@code offset+N >= a.length}
* for any lane {@code N} in the vector
* where the mask is set
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset,
VectorMask<$Boxtype$> m) {
if (m.allTrue()) {
intoBooleanArray(a, offset);
} else {
// FIXME: optimize
$Type$Species vsp = vspecies();
checkMaskFromIndexSize(offset, vsp, m, 1, a.length);
stOp(a, offset, m, (arr, off, i, e) -> arr[off+i] = (e & 1) != 0);
}
}
/**
* Scatters this vector into an array of type {@code boolean[]}
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset,
int[] indexMap, int mapOffset) {
// FIXME: optimize
stOp(a, offset,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (e & 1) != 0;
});
}
/**
* Scatters this vector into an array of type {@code boolean[]},
* under the control of a mask, and
* using indexes obtained by adding a fixed {@code offset} to a
* series of secondary offsets from an <em>index map</em>.
* The index map is a contiguous sequence of {@code VLENGTH}
* elements in a second array of {@code int}s, starting at a given
* {@code mapOffset}.
* <p>
* For each vector lane, where {@code N} is the vector lane index,
* if the mask lane at index {@code N} is set then
* the lane element at index {@code N}
* is first converted to a {@code boolean} value and then
* stored into the array
* element {@code a[f(N)]}, where {@code f(N)} is the
* index mapping expression
* {@code offset + indexMap[mapOffset + N]]}.
* <p>
* A {@code byte} value is converted to a {@code boolean} value by applying the
* expression {@code (b & 1) != 0} where {@code b} is the byte value.
*
* @param a the array
* @param offset an offset to combine with the index map offsets
* @param indexMap the index map
* @param mapOffset the offset into the index map
* @param m the mask
* @throws IndexOutOfBoundsException
* if {@code mapOffset+N < 0}
* or if {@code mapOffset+N >= indexMap.length},
* or if {@code f(N)=offset+indexMap[mapOffset+N]}
* is an invalid index into {@code a},
* for any lane {@code N} in the vector
* where the mask is set
* @see $abstractvectortype$#toIntArray()
*/
@ForceInline
public final
void intoBooleanArray(boolean[] a, int offset,
int[] indexMap, int mapOffset,
VectorMask<$Boxtype$> m) {
// FIXME: optimize
stOp(a, offset, m,
(arr, off, i, e) -> {
int j = indexMap[mapOffset + i];
arr[off + j] = (e & 1) != 0;
});
}
#end[byte]
/** /**
* {@inheritDoc} <!--workaround--> * {@inheritDoc} <!--workaround-->
*/ */
@ -3810,6 +4440,40 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
(arr_, off_, i) -> arr_[off_ + i])); (arr_, off_, i) -> arr_[off_ + i]));
} }
#if[short]
/*package-private*/
abstract
$abstractvectortype$ fromCharArray0(char[] a, int offset);
@ForceInline
final
$abstractvectortype$ fromCharArray0Template(char[] a, int offset) {
$Type$Species vsp = vspecies();
return VectorSupport.load(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, charArrayAddress(a, offset),
a, offset, vsp,
(arr, off, s) -> s.ldOp(arr, off,
(arr_, off_, i) -> (short) arr_[off_ + i]));
}
#end[short]
#if[byte]
/*package-private*/
abstract
$abstractvectortype$ fromBooleanArray0(boolean[] a, int offset);
@ForceInline
final
$abstractvectortype$ fromBooleanArray0Template(boolean[] a, int offset) {
$Type$Species vsp = vspecies();
return VectorSupport.load(
vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
a, booleanArrayAddress(a, offset),
a, offset, vsp,
(arr, off, s) -> s.ldOp(arr, off,
(arr_, off_, i) -> (byte) (arr_[off_ + i] ? 1 : 0)));
}
#end[byte]
@Override @Override
abstract abstract
$abstractvectortype$ fromByteArray0(byte[] a, int offset); $abstractvectortype$ fromByteArray0(byte[] a, int offset);
@ -3947,6 +4611,30 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); return ARRAY_BASE + (((long)index) << ARRAY_SHIFT);
} }
#if[short]
static final int ARRAY_CHAR_SHIFT =
31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_CHAR_INDEX_SCALE);
static final long ARRAY_CHAR_BASE =
Unsafe.ARRAY_CHAR_BASE_OFFSET;
@ForceInline
static long charArrayAddress(char[] a, int index) {
return ARRAY_CHAR_BASE + (((long)index) << ARRAY_CHAR_SHIFT);
}
#end[short]
#if[byte]
static final int ARRAY_BOOLEAN_SHIFT =
31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
static final long ARRAY_BOOLEAN_BASE =
Unsafe.ARRAY_BOOLEAN_BASE_OFFSET;
@ForceInline
static long booleanArrayAddress(boolean[] a, int index) {
return ARRAY_BOOLEAN_BASE + (((long)index) << ARRAY_BOOLEAN_SHIFT);
}
#end[byte]
@ForceInline @ForceInline
static long byteArrayAddress(byte[] a, int index) { static long byteArrayAddress(byte[] a, int index) {
return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; return Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

View file

@ -1092,6 +1092,24 @@ final class $vectortype$ extends $abstractvectortype$ {
return super.fromArray0Template(a, offset); // specialize return super.fromArray0Template(a, offset); // specialize
} }
#if[short]
@ForceInline
@Override
final
$abstractvectortype$ fromCharArray0(char[] a, int offset) {
return super.fromCharArray0Template(a, offset); // specialize
}
#end[short]
#if[byte]
@ForceInline
@Override
final
$abstractvectortype$ fromBooleanArray0(boolean[] a, int offset) {
return super.fromBooleanArray0Template(a, offset); // specialize
}
#end[byte]
@ForceInline @ForceInline
@Override @Override
final final

View file

@ -948,4 +948,94 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
static void assertArraysEquals(boolean[] r, byte[] a) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], (a[i] & 1) == 1);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], (a[i] & 1) == 1, "at index #" + i);
}
}
static void assertArraysEquals(boolean[] r, boolean[] a, boolean[] mask) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i]);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i], "at index #" + i);
}
}
static boolean[] convertToBooleanArray(byte[] a) {
boolean[] r = new boolean[a.length];
for (int i = 0; i < a.length; i++) {
r[i] = (a[i] & 1) == 1;
}
return r;
}
@Test(dataProvider = "byteProvider")
static void loadByteStoreBooleanArray(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a);
}
@Test(dataProvider = "byteProvider")
static void loadStoreBooleanArray(IntFunction<byte[]> fa) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
Assert.assertEquals(r, a);
}
@Test(dataProvider = "byteMaskProvider")
static void loadStoreMaskBooleanArray(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, vmask);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a, mask);
r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i, vmask);
}
}
assertArraysEquals(r, a, mask);
}
} }

View file

@ -980,8 +980,9 @@ public class Byte128VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
byte[] a = new byte[l]; byte[] a = new byte[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (byte)RAND.nextInt(m); a[i] = (byte)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1042,6 +1043,10 @@ public class Byte128VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)i); i -> (byte)i);
}), }),
withToString("byte[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (byte)(i - (s * BUFFER_REPS / 2)));
}),
withToString("byte[i + 1]", (int s) -> { withToString("byte[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)(i + 1)); i -> (byte)(i + 1));
@ -1165,6 +1170,46 @@ public class Byte128VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(byte a, byte b) {
return a == b;
}
static boolean neq(byte a, byte b) {
return a != b;
}
static boolean lt(byte a, byte b) {
return a < b;
}
static boolean le(byte a, byte b) {
return a <= b;
}
static boolean gt(byte a, byte b) {
return a > b;
}
static boolean ge(byte a, byte b) {
return a >= b;
}
static boolean ult(byte a, byte b) {
return Byte.compareUnsigned(a, b) < 0;
}
static boolean ule(byte a, byte b) {
return Byte.compareUnsigned(a, b) <= 0;
}
static boolean ugt(byte a, byte b) {
return Byte.compareUnsigned(a, b) > 0;
}
static boolean uge(byte a, byte b) {
return Byte.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3);
@ -3337,7 +3382,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3357,7 +3402,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3380,7 +3425,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3400,7 +3445,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3423,7 +3468,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3443,7 +3488,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3463,7 +3508,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3486,7 +3531,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3506,7 +3551,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3529,7 +3574,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3549,7 +3594,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3572,7 +3617,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3592,7 +3637,7 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3615,13 +3660,201 @@ public class Byte128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LTByte128VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LTByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GTByte128VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GTByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LEByte128VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LEByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GEByte128VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GEByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider") @Test(dataProvider = "byteCompareOpProvider")
static void LTByte128VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { static void LTByte128VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length()); byte[] a = fa.apply(SPECIES.length());

View file

@ -948,4 +948,94 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
static void assertArraysEquals(boolean[] r, byte[] a) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], (a[i] & 1) == 1);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], (a[i] & 1) == 1, "at index #" + i);
}
}
static void assertArraysEquals(boolean[] r, boolean[] a, boolean[] mask) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i]);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i], "at index #" + i);
}
}
static boolean[] convertToBooleanArray(byte[] a) {
boolean[] r = new boolean[a.length];
for (int i = 0; i < a.length; i++) {
r[i] = (a[i] & 1) == 1;
}
return r;
}
@Test(dataProvider = "byteProvider")
static void loadByteStoreBooleanArray(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a);
}
@Test(dataProvider = "byteProvider")
static void loadStoreBooleanArray(IntFunction<byte[]> fa) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
Assert.assertEquals(r, a);
}
@Test(dataProvider = "byteMaskProvider")
static void loadStoreMaskBooleanArray(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, vmask);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a, mask);
r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i, vmask);
}
}
assertArraysEquals(r, a, mask);
}
} }

View file

@ -980,8 +980,9 @@ public class Byte256VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
byte[] a = new byte[l]; byte[] a = new byte[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (byte)RAND.nextInt(m); a[i] = (byte)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1042,6 +1043,10 @@ public class Byte256VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)i); i -> (byte)i);
}), }),
withToString("byte[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (byte)(i - (s * BUFFER_REPS / 2)));
}),
withToString("byte[i + 1]", (int s) -> { withToString("byte[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)(i + 1)); i -> (byte)(i + 1));
@ -1165,6 +1170,46 @@ public class Byte256VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(byte a, byte b) {
return a == b;
}
static boolean neq(byte a, byte b) {
return a != b;
}
static boolean lt(byte a, byte b) {
return a < b;
}
static boolean le(byte a, byte b) {
return a <= b;
}
static boolean gt(byte a, byte b) {
return a > b;
}
static boolean ge(byte a, byte b) {
return a >= b;
}
static boolean ult(byte a, byte b) {
return Byte.compareUnsigned(a, b) < 0;
}
static boolean ule(byte a, byte b) {
return Byte.compareUnsigned(a, b) <= 0;
}
static boolean ugt(byte a, byte b) {
return Byte.compareUnsigned(a, b) > 0;
}
static boolean uge(byte a, byte b) {
return Byte.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3);
@ -3337,7 +3382,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3357,7 +3402,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3380,7 +3425,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3400,7 +3445,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3423,7 +3468,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3443,7 +3488,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3463,7 +3508,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3486,7 +3531,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3506,7 +3551,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3529,7 +3574,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3549,7 +3594,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3572,7 +3617,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3592,7 +3637,7 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3615,13 +3660,201 @@ public class Byte256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LTByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LTByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GTByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GTByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LEByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GEByte256VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GEByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider") @Test(dataProvider = "byteCompareOpProvider")
static void LTByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { static void LTByte256VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length()); byte[] a = fa.apply(SPECIES.length());

View file

@ -948,4 +948,94 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
static void assertArraysEquals(boolean[] r, byte[] a) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], (a[i] & 1) == 1);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], (a[i] & 1) == 1, "at index #" + i);
}
}
static void assertArraysEquals(boolean[] r, boolean[] a, boolean[] mask) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i]);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i], "at index #" + i);
}
}
static boolean[] convertToBooleanArray(byte[] a) {
boolean[] r = new boolean[a.length];
for (int i = 0; i < a.length; i++) {
r[i] = (a[i] & 1) == 1;
}
return r;
}
@Test(dataProvider = "byteProvider")
static void loadByteStoreBooleanArray(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a);
}
@Test(dataProvider = "byteProvider")
static void loadStoreBooleanArray(IntFunction<byte[]> fa) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
Assert.assertEquals(r, a);
}
@Test(dataProvider = "byteMaskProvider")
static void loadStoreMaskBooleanArray(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, vmask);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a, mask);
r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i, vmask);
}
}
assertArraysEquals(r, a, mask);
}
} }

View file

@ -980,8 +980,9 @@ public class Byte512VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
byte[] a = new byte[l]; byte[] a = new byte[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (byte)RAND.nextInt(m); a[i] = (byte)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1042,6 +1043,10 @@ public class Byte512VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)i); i -> (byte)i);
}), }),
withToString("byte[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (byte)(i - (s * BUFFER_REPS / 2)));
}),
withToString("byte[i + 1]", (int s) -> { withToString("byte[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)(i + 1)); i -> (byte)(i + 1));
@ -1165,6 +1170,46 @@ public class Byte512VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(byte a, byte b) {
return a == b;
}
static boolean neq(byte a, byte b) {
return a != b;
}
static boolean lt(byte a, byte b) {
return a < b;
}
static boolean le(byte a, byte b) {
return a <= b;
}
static boolean gt(byte a, byte b) {
return a > b;
}
static boolean ge(byte a, byte b) {
return a >= b;
}
static boolean ult(byte a, byte b) {
return Byte.compareUnsigned(a, b) < 0;
}
static boolean ule(byte a, byte b) {
return Byte.compareUnsigned(a, b) <= 0;
}
static boolean ugt(byte a, byte b) {
return Byte.compareUnsigned(a, b) > 0;
}
static boolean uge(byte a, byte b) {
return Byte.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3);
@ -3337,7 +3382,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3357,7 +3402,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3380,7 +3425,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3400,7 +3445,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3423,7 +3468,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3443,7 +3488,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3463,7 +3508,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3486,7 +3531,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3506,7 +3551,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3529,7 +3574,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3549,7 +3594,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3572,7 +3617,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3592,7 +3637,7 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3615,13 +3660,201 @@ public class Byte512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LTByte512VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LTByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GTByte512VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GTByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LEByte512VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LEByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GEByte512VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GEByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider") @Test(dataProvider = "byteCompareOpProvider")
static void LTByte512VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { static void LTByte512VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length()); byte[] a = fa.apply(SPECIES.length());

View file

@ -948,4 +948,94 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
static void assertArraysEquals(boolean[] r, byte[] a) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], (a[i] & 1) == 1);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], (a[i] & 1) == 1, "at index #" + i);
}
}
static void assertArraysEquals(boolean[] r, boolean[] a, boolean[] mask) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i]);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i], "at index #" + i);
}
}
static boolean[] convertToBooleanArray(byte[] a) {
boolean[] r = new boolean[a.length];
for (int i = 0; i < a.length; i++) {
r[i] = (a[i] & 1) == 1;
}
return r;
}
@Test(dataProvider = "byteProvider")
static void loadByteStoreBooleanArray(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a);
}
@Test(dataProvider = "byteProvider")
static void loadStoreBooleanArray(IntFunction<byte[]> fa) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
Assert.assertEquals(r, a);
}
@Test(dataProvider = "byteMaskProvider")
static void loadStoreMaskBooleanArray(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, vmask);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a, mask);
r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i, vmask);
}
}
assertArraysEquals(r, a, mask);
}
} }

View file

@ -980,8 +980,9 @@ public class Byte64VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
byte[] a = new byte[l]; byte[] a = new byte[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (byte)RAND.nextInt(m); a[i] = (byte)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1042,6 +1043,10 @@ public class Byte64VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)i); i -> (byte)i);
}), }),
withToString("byte[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (byte)(i - (s * BUFFER_REPS / 2)));
}),
withToString("byte[i + 1]", (int s) -> { withToString("byte[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)(i + 1)); i -> (byte)(i + 1));
@ -1165,6 +1170,46 @@ public class Byte64VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(byte a, byte b) {
return a == b;
}
static boolean neq(byte a, byte b) {
return a != b;
}
static boolean lt(byte a, byte b) {
return a < b;
}
static boolean le(byte a, byte b) {
return a <= b;
}
static boolean gt(byte a, byte b) {
return a > b;
}
static boolean ge(byte a, byte b) {
return a >= b;
}
static boolean ult(byte a, byte b) {
return Byte.compareUnsigned(a, b) < 0;
}
static boolean ule(byte a, byte b) {
return Byte.compareUnsigned(a, b) <= 0;
}
static boolean ugt(byte a, byte b) {
return Byte.compareUnsigned(a, b) > 0;
}
static boolean uge(byte a, byte b) {
return Byte.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3);
@ -3337,7 +3382,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3357,7 +3402,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3380,7 +3425,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3400,7 +3445,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3423,7 +3468,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3443,7 +3488,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3463,7 +3508,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3486,7 +3531,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3506,7 +3551,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3529,7 +3574,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3549,7 +3594,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3572,7 +3617,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3592,7 +3637,7 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3615,13 +3660,201 @@ public class Byte64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LTByte64VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LTByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GTByte64VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GTByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LEByte64VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LEByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GEByte64VectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GEByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider") @Test(dataProvider = "byteCompareOpProvider")
static void LTByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { static void LTByte64VectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length()); byte[] a = fa.apply(SPECIES.length());

View file

@ -957,4 +957,94 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
static void assertArraysEquals(boolean[] r, byte[] a) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], (a[i] & 1) == 1);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], (a[i] & 1) == 1, "at index #" + i);
}
}
static void assertArraysEquals(boolean[] r, boolean[] a, boolean[] mask) {
int i = 0;
try {
for (; i < a.length; i++) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i]);
}
} catch (AssertionError e) {
Assert.assertEquals(r[i], mask[i % SPECIES.length()] && a[i], "at index #" + i);
}
}
static boolean[] convertToBooleanArray(byte[] a) {
boolean[] r = new boolean[a.length];
for (int i = 0; i < a.length; i++) {
r[i] = (a[i] & 1) == 1;
}
return r;
}
@Test(dataProvider = "byteProvider")
static void loadByteStoreBooleanArray(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a);
}
@Test(dataProvider = "byteProvider")
static void loadStoreBooleanArray(IntFunction<byte[]> fa) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i);
}
}
Assert.assertEquals(r, a);
}
@Test(dataProvider = "byteMaskProvider")
static void loadStoreMaskBooleanArray(IntFunction<byte[]> fa,
IntFunction<boolean[]> fm) {
boolean[] a = convertToBooleanArray(fa.apply(SPECIES.length()));
boolean[] r = new boolean[a.length];
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i, vmask);
av.intoBooleanArray(r, i);
}
}
assertArraysEquals(r, a, mask);
r = new boolean[a.length];
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromBooleanArray(SPECIES, a, i);
av.intoBooleanArray(r, i, vmask);
}
}
assertArraysEquals(r, a, mask);
}
} }

View file

@ -985,8 +985,9 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,byte[]>> BYTE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
byte[] a = new byte[l]; byte[] a = new byte[l];
int upper = Math.min(Byte.MAX_VALUE + 1, m);
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (byte)RAND.nextInt(m); a[i] = (byte)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1047,6 +1048,10 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)i); i -> (byte)i);
}), }),
withToString("byte[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (byte)(i - (s * BUFFER_REPS / 2)));
}),
withToString("byte[i + 1]", (int s) -> { withToString("byte[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (byte)(i + 1)); i -> (byte)(i + 1));
@ -1170,6 +1175,46 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(byte a, byte b) {
return a == b;
}
static boolean neq(byte a, byte b) {
return a != b;
}
static boolean lt(byte a, byte b) {
return a < b;
}
static boolean le(byte a, byte b) {
return a <= b;
}
static boolean gt(byte a, byte b) {
return a > b;
}
static boolean ge(byte a, byte b) {
return a >= b;
}
static boolean ult(byte a, byte b) {
return Byte.compareUnsigned(a, b) < 0;
}
static boolean ule(byte a, byte b) {
return Byte.compareUnsigned(a, b) <= 0;
}
static boolean ugt(byte a, byte b) {
return Byte.compareUnsigned(a, b) > 0;
}
static boolean uge(byte a, byte b) {
return Byte.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3);
@ -3342,7 +3387,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3362,7 +3407,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3385,7 +3430,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3405,7 +3450,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3428,7 +3473,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3448,7 +3493,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3468,7 +3513,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3491,7 +3536,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3511,7 +3556,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3534,7 +3579,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3554,7 +3599,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3577,7 +3622,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3597,7 +3642,7 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3620,13 +3665,201 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_LEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_LEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider")
static void UNSIGNED_GEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpMaskProvider")
static void UNSIGNED_GEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "byteCompareOpProvider") @Test(dataProvider = "byteCompareOpProvider")
static void LTByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) { static void LTByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
byte[] a = fa.apply(SPECIES.length()); byte[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Double128VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1112,8 +1112,9 @@ public class Double128VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
double[] a = new double[l]; double[] a = new double[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (double)RAND.nextInt(m); a[i] = (double)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1174,6 +1175,10 @@ public class Double128VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)i); i -> (double)i);
}), }),
withToString("double[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (double)(i - (s * BUFFER_REPS / 2)));
}),
withToString("double[i + 1]", (int s) -> { withToString("double[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)(i + 1)); i -> (double)(i + 1));
@ -1286,6 +1291,31 @@ public class Double128VectorTests extends AbstractVectorTest {
}; };
static boolean eq(double a, double b) {
return a == b;
}
static boolean neq(double a, double b) {
return a != b;
}
static boolean lt(double a, double b) {
return a < b;
}
static boolean le(double a, double b) {
return a <= b;
}
static boolean gt(double a, double b) {
return a > b;
}
static boolean ge(double a, double b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
@ -2654,7 +2684,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2674,7 +2704,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2697,7 +2727,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2717,7 +2747,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2740,7 +2770,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2760,7 +2790,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2780,7 +2810,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2803,7 +2833,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2823,7 +2853,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2846,7 +2876,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2866,7 +2896,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2889,7 +2919,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2909,7 +2939,7 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2932,13 +2962,21 @@ public class Double128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "doubleCompareOpProvider") @Test(dataProvider = "doubleCompareOpProvider")
static void LTDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) { static void LTDouble128VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length()); double[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Double256VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1112,8 +1112,9 @@ public class Double256VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
double[] a = new double[l]; double[] a = new double[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (double)RAND.nextInt(m); a[i] = (double)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1174,6 +1175,10 @@ public class Double256VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)i); i -> (double)i);
}), }),
withToString("double[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (double)(i - (s * BUFFER_REPS / 2)));
}),
withToString("double[i + 1]", (int s) -> { withToString("double[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)(i + 1)); i -> (double)(i + 1));
@ -1286,6 +1291,31 @@ public class Double256VectorTests extends AbstractVectorTest {
}; };
static boolean eq(double a, double b) {
return a == b;
}
static boolean neq(double a, double b) {
return a != b;
}
static boolean lt(double a, double b) {
return a < b;
}
static boolean le(double a, double b) {
return a <= b;
}
static boolean gt(double a, double b) {
return a > b;
}
static boolean ge(double a, double b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
@ -2654,7 +2684,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2674,7 +2704,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2697,7 +2727,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2717,7 +2747,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2740,7 +2770,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2760,7 +2790,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2780,7 +2810,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2803,7 +2833,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2823,7 +2853,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2846,7 +2876,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2866,7 +2896,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2889,7 +2919,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2909,7 +2939,7 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2932,13 +2962,21 @@ public class Double256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "doubleCompareOpProvider") @Test(dataProvider = "doubleCompareOpProvider")
static void LTDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) { static void LTDouble256VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length()); double[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Double512VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1112,8 +1112,9 @@ public class Double512VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
double[] a = new double[l]; double[] a = new double[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (double)RAND.nextInt(m); a[i] = (double)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1174,6 +1175,10 @@ public class Double512VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)i); i -> (double)i);
}), }),
withToString("double[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (double)(i - (s * BUFFER_REPS / 2)));
}),
withToString("double[i + 1]", (int s) -> { withToString("double[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)(i + 1)); i -> (double)(i + 1));
@ -1286,6 +1291,31 @@ public class Double512VectorTests extends AbstractVectorTest {
}; };
static boolean eq(double a, double b) {
return a == b;
}
static boolean neq(double a, double b) {
return a != b;
}
static boolean lt(double a, double b) {
return a < b;
}
static boolean le(double a, double b) {
return a <= b;
}
static boolean gt(double a, double b) {
return a > b;
}
static boolean ge(double a, double b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
@ -2654,7 +2684,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2674,7 +2704,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2697,7 +2727,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2717,7 +2747,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2740,7 +2770,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2760,7 +2790,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2780,7 +2810,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2803,7 +2833,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2823,7 +2853,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2846,7 +2876,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2866,7 +2896,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2889,7 +2919,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2909,7 +2939,7 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2932,13 +2962,21 @@ public class Double512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "doubleCompareOpProvider") @Test(dataProvider = "doubleCompareOpProvider")
static void LTDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) { static void LTDouble512VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length()); double[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Double64VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1112,8 +1112,9 @@ public class Double64VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
double[] a = new double[l]; double[] a = new double[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (double)RAND.nextInt(m); a[i] = (double)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1174,6 +1175,10 @@ public class Double64VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)i); i -> (double)i);
}), }),
withToString("double[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (double)(i - (s * BUFFER_REPS / 2)));
}),
withToString("double[i + 1]", (int s) -> { withToString("double[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)(i + 1)); i -> (double)(i + 1));
@ -1286,6 +1291,31 @@ public class Double64VectorTests extends AbstractVectorTest {
}; };
static boolean eq(double a, double b) {
return a == b;
}
static boolean neq(double a, double b) {
return a != b;
}
static boolean lt(double a, double b) {
return a < b;
}
static boolean le(double a, double b) {
return a <= b;
}
static boolean gt(double a, double b) {
return a > b;
}
static boolean ge(double a, double b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
@ -2654,7 +2684,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2674,7 +2704,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2697,7 +2727,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2717,7 +2747,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2740,7 +2770,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2760,7 +2790,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2780,7 +2810,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2803,7 +2833,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2823,7 +2853,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2846,7 +2876,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2866,7 +2896,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2889,7 +2919,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2909,7 +2939,7 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2932,13 +2962,21 @@ public class Double64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "doubleCompareOpProvider") @Test(dataProvider = "doubleCompareOpProvider")
static void LTDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) { static void LTDouble64VectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length()); double[] a = fa.apply(SPECIES.length());

View file

@ -968,4 +968,7 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1117,8 +1117,9 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,double[]>> DOUBLE_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
double[] a = new double[l]; double[] a = new double[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (double)RAND.nextInt(m); a[i] = (double)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1179,6 +1180,10 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)i); i -> (double)i);
}), }),
withToString("double[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (double)(i - (s * BUFFER_REPS / 2)));
}),
withToString("double[i + 1]", (int s) -> { withToString("double[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (double)(i + 1)); i -> (double)(i + 1));
@ -1291,6 +1296,31 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
}; };
static boolean eq(double a, double b) {
return a == b;
}
static boolean neq(double a, double b) {
return a != b;
}
static boolean lt(double a, double b) {
return a < b;
}
static boolean le(double a, double b) {
return a <= b;
}
static boolean gt(double a, double b) {
return a > b;
}
static boolean ge(double a, double b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3);
@ -2659,7 +2689,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2679,7 +2709,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2702,7 +2732,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2722,7 +2752,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2745,7 +2775,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2765,7 +2795,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2785,7 +2815,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2808,7 +2838,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2828,7 +2858,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2851,7 +2881,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2871,7 +2901,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2894,7 +2924,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2914,7 +2944,7 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2937,13 +2967,21 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "doubleCompareOpProvider") @Test(dataProvider = "doubleCompareOpProvider")
static void LTDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) { static void LTDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction<double[]> fa, IntFunction<double[]> fb) {
double[] a = fa.apply(SPECIES.length()); double[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Float128VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1122,8 +1122,9 @@ public class Float128VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
float[] a = new float[l]; float[] a = new float[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (float)RAND.nextInt(m); a[i] = (float)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1184,6 +1185,10 @@ public class Float128VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)i); i -> (float)i);
}), }),
withToString("float[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (float)(i - (s * BUFFER_REPS / 2)));
}),
withToString("float[i + 1]", (int s) -> { withToString("float[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)(i + 1)); i -> (float)(i + 1));
@ -1296,6 +1301,31 @@ public class Float128VectorTests extends AbstractVectorTest {
}; };
static boolean eq(float a, float b) {
return a == b;
}
static boolean neq(float a, float b) {
return a != b;
}
static boolean lt(float a, float b) {
return a < b;
}
static boolean le(float a, float b) {
return a <= b;
}
static boolean gt(float a, float b) {
return a > b;
}
static boolean ge(float a, float b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3);
@ -2664,7 +2694,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2684,7 +2714,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2707,7 +2737,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2727,7 +2757,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2750,7 +2780,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2770,7 +2800,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2790,7 +2820,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2813,7 +2843,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2833,7 +2863,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2856,7 +2886,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2876,7 +2906,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2899,7 +2929,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2919,7 +2949,7 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2942,13 +2972,21 @@ public class Float128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "floatCompareOpProvider") @Test(dataProvider = "floatCompareOpProvider")
static void LTFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) { static void LTFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length()); float[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Float256VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1122,8 +1122,9 @@ public class Float256VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
float[] a = new float[l]; float[] a = new float[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (float)RAND.nextInt(m); a[i] = (float)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1184,6 +1185,10 @@ public class Float256VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)i); i -> (float)i);
}), }),
withToString("float[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (float)(i - (s * BUFFER_REPS / 2)));
}),
withToString("float[i + 1]", (int s) -> { withToString("float[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)(i + 1)); i -> (float)(i + 1));
@ -1296,6 +1301,31 @@ public class Float256VectorTests extends AbstractVectorTest {
}; };
static boolean eq(float a, float b) {
return a == b;
}
static boolean neq(float a, float b) {
return a != b;
}
static boolean lt(float a, float b) {
return a < b;
}
static boolean le(float a, float b) {
return a <= b;
}
static boolean gt(float a, float b) {
return a > b;
}
static boolean ge(float a, float b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3);
@ -2664,7 +2694,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2684,7 +2714,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2707,7 +2737,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2727,7 +2757,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2750,7 +2780,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2770,7 +2800,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2790,7 +2820,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2813,7 +2843,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2833,7 +2863,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2856,7 +2886,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2876,7 +2906,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2899,7 +2929,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2919,7 +2949,7 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2942,13 +2972,21 @@ public class Float256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "floatCompareOpProvider") @Test(dataProvider = "floatCompareOpProvider")
static void LTFloat256VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) { static void LTFloat256VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length()); float[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Float512VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1122,8 +1122,9 @@ public class Float512VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
float[] a = new float[l]; float[] a = new float[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (float)RAND.nextInt(m); a[i] = (float)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1184,6 +1185,10 @@ public class Float512VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)i); i -> (float)i);
}), }),
withToString("float[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (float)(i - (s * BUFFER_REPS / 2)));
}),
withToString("float[i + 1]", (int s) -> { withToString("float[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)(i + 1)); i -> (float)(i + 1));
@ -1296,6 +1301,31 @@ public class Float512VectorTests extends AbstractVectorTest {
}; };
static boolean eq(float a, float b) {
return a == b;
}
static boolean neq(float a, float b) {
return a != b;
}
static boolean lt(float a, float b) {
return a < b;
}
static boolean le(float a, float b) {
return a <= b;
}
static boolean gt(float a, float b) {
return a > b;
}
static boolean ge(float a, float b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3);
@ -2664,7 +2694,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2684,7 +2714,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2707,7 +2737,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2727,7 +2757,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2750,7 +2780,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2770,7 +2800,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2790,7 +2820,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2813,7 +2843,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2833,7 +2863,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2856,7 +2886,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2876,7 +2906,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2899,7 +2929,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2919,7 +2949,7 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2942,13 +2972,21 @@ public class Float512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "floatCompareOpProvider") @Test(dataProvider = "floatCompareOpProvider")
static void LTFloat512VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) { static void LTFloat512VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length()); float[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Float64VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1122,8 +1122,9 @@ public class Float64VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
float[] a = new float[l]; float[] a = new float[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (float)RAND.nextInt(m); a[i] = (float)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1184,6 +1185,10 @@ public class Float64VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)i); i -> (float)i);
}), }),
withToString("float[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (float)(i - (s * BUFFER_REPS / 2)));
}),
withToString("float[i + 1]", (int s) -> { withToString("float[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)(i + 1)); i -> (float)(i + 1));
@ -1296,6 +1301,31 @@ public class Float64VectorTests extends AbstractVectorTest {
}; };
static boolean eq(float a, float b) {
return a == b;
}
static boolean neq(float a, float b) {
return a != b;
}
static boolean lt(float a, float b) {
return a < b;
}
static boolean le(float a, float b) {
return a <= b;
}
static boolean gt(float a, float b) {
return a > b;
}
static boolean ge(float a, float b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3);
@ -2664,7 +2694,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2684,7 +2714,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2707,7 +2737,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2727,7 +2757,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2750,7 +2780,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2770,7 +2800,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2790,7 +2820,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2813,7 +2843,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2833,7 +2863,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2856,7 +2886,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2876,7 +2906,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2899,7 +2929,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2919,7 +2949,7 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2942,13 +2972,21 @@ public class Float64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "floatCompareOpProvider") @Test(dataProvider = "floatCompareOpProvider")
static void LTFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) { static void LTFloat64VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length()); float[] a = fa.apply(SPECIES.length());

View file

@ -968,4 +968,7 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1127,8 +1127,9 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
float[] a = new float[l]; float[] a = new float[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (float)RAND.nextInt(m); a[i] = (float)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1189,6 +1190,10 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)i); i -> (float)i);
}), }),
withToString("float[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (float)(i - (s * BUFFER_REPS / 2)));
}),
withToString("float[i + 1]", (int s) -> { withToString("float[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (float)(i + 1)); i -> (float)(i + 1));
@ -1301,6 +1306,31 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
}; };
static boolean eq(float a, float b) {
return a == b;
}
static boolean neq(float a, float b) {
return a != b;
}
static boolean lt(float a, float b) {
return a < b;
}
static boolean le(float a, float b) {
return a <= b;
}
static boolean gt(float a, float b) {
return a > b;
}
static boolean ge(float a, float b) {
return a >= b;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3);
@ -2669,7 +2699,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2689,7 +2719,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2712,7 +2742,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -2732,7 +2762,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2755,7 +2785,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -2775,7 +2805,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2795,7 +2825,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2818,7 +2848,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -2838,7 +2868,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2861,7 +2891,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -2881,7 +2911,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -2904,7 +2934,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -2924,7 +2954,7 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -2947,13 +2977,21 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "floatCompareOpProvider") @Test(dataProvider = "floatCompareOpProvider")
static void LTFloatMaxVectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) { static void LTFloatMaxVectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {
float[] a = fa.apply(SPECIES.length()); float[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Int128VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1003,6 +1003,10 @@ public class Int128VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)i); i -> (int)i);
}), }),
withToString("int[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (int)(i - (s * BUFFER_REPS / 2)));
}),
withToString("int[i + 1]", (int s) -> { withToString("int[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)(i + 1)); i -> (int)(i + 1));
@ -1126,6 +1130,46 @@ public class Int128VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(int a, int b) {
return a == b;
}
static boolean neq(int a, int b) {
return a != b;
}
static boolean lt(int a, int b) {
return a < b;
}
static boolean le(int a, int b) {
return a <= b;
}
static boolean gt(int a, int b) {
return a > b;
}
static boolean ge(int a, int b) {
return a >= b;
}
static boolean ult(int a, int b) {
return Integer.compareUnsigned(a, b) < 0;
}
static boolean ule(int a, int b) {
return Integer.compareUnsigned(a, b) <= 0;
}
static boolean ugt(int a, int b) {
return Integer.compareUnsigned(a, b) > 0;
}
static boolean uge(int a, int b) {
return Integer.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
IntVector three = IntVector.broadcast(SPECIES, (byte)-3); IntVector three = IntVector.broadcast(SPECIES, (byte)-3);
@ -3303,7 +3347,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3323,7 +3367,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3346,7 +3390,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3366,7 +3410,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3389,7 +3433,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3409,7 +3453,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3429,7 +3473,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3452,7 +3496,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3472,7 +3516,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3495,7 +3539,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3515,7 +3559,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3538,7 +3582,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3558,7 +3602,7 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3581,13 +3625,201 @@ public class Int128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GTInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GTInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GEInt128VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GEInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider") @Test(dataProvider = "intCompareOpProvider")
static void LTInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) { static void LTInt128VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length()); int[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Int256VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1003,6 +1003,10 @@ public class Int256VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)i); i -> (int)i);
}), }),
withToString("int[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (int)(i - (s * BUFFER_REPS / 2)));
}),
withToString("int[i + 1]", (int s) -> { withToString("int[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)(i + 1)); i -> (int)(i + 1));
@ -1126,6 +1130,46 @@ public class Int256VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(int a, int b) {
return a == b;
}
static boolean neq(int a, int b) {
return a != b;
}
static boolean lt(int a, int b) {
return a < b;
}
static boolean le(int a, int b) {
return a <= b;
}
static boolean gt(int a, int b) {
return a > b;
}
static boolean ge(int a, int b) {
return a >= b;
}
static boolean ult(int a, int b) {
return Integer.compareUnsigned(a, b) < 0;
}
static boolean ule(int a, int b) {
return Integer.compareUnsigned(a, b) <= 0;
}
static boolean ugt(int a, int b) {
return Integer.compareUnsigned(a, b) > 0;
}
static boolean uge(int a, int b) {
return Integer.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
IntVector three = IntVector.broadcast(SPECIES, (byte)-3); IntVector three = IntVector.broadcast(SPECIES, (byte)-3);
@ -3303,7 +3347,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3323,7 +3367,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3346,7 +3390,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3366,7 +3410,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3389,7 +3433,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3409,7 +3453,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3429,7 +3473,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3452,7 +3496,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3472,7 +3516,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3495,7 +3539,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3515,7 +3559,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3538,7 +3582,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3558,7 +3602,7 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3581,13 +3625,201 @@ public class Int256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LTInt256VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LTInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GTInt256VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GTInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LEInt256VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LEInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GEInt256VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GEInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider") @Test(dataProvider = "intCompareOpProvider")
static void LTInt256VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) { static void LTInt256VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length()); int[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Int512VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1003,6 +1003,10 @@ public class Int512VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)i); i -> (int)i);
}), }),
withToString("int[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (int)(i - (s * BUFFER_REPS / 2)));
}),
withToString("int[i + 1]", (int s) -> { withToString("int[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)(i + 1)); i -> (int)(i + 1));
@ -1126,6 +1130,46 @@ public class Int512VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(int a, int b) {
return a == b;
}
static boolean neq(int a, int b) {
return a != b;
}
static boolean lt(int a, int b) {
return a < b;
}
static boolean le(int a, int b) {
return a <= b;
}
static boolean gt(int a, int b) {
return a > b;
}
static boolean ge(int a, int b) {
return a >= b;
}
static boolean ult(int a, int b) {
return Integer.compareUnsigned(a, b) < 0;
}
static boolean ule(int a, int b) {
return Integer.compareUnsigned(a, b) <= 0;
}
static boolean ugt(int a, int b) {
return Integer.compareUnsigned(a, b) > 0;
}
static boolean uge(int a, int b) {
return Integer.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
IntVector three = IntVector.broadcast(SPECIES, (byte)-3); IntVector three = IntVector.broadcast(SPECIES, (byte)-3);
@ -3303,7 +3347,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3323,7 +3367,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3346,7 +3390,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3366,7 +3410,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3389,7 +3433,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3409,7 +3453,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3429,7 +3473,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3452,7 +3496,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3472,7 +3516,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3495,7 +3539,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3515,7 +3559,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3538,7 +3582,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3558,7 +3602,7 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3581,13 +3625,201 @@ public class Int512VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LTInt512VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LTInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GTInt512VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GTInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LEInt512VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LEInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GEInt512VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GEInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider") @Test(dataProvider = "intCompareOpProvider")
static void LTInt512VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) { static void LTInt512VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length()); int[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Int64VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1003,6 +1003,10 @@ public class Int64VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)i); i -> (int)i);
}), }),
withToString("int[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (int)(i - (s * BUFFER_REPS / 2)));
}),
withToString("int[i + 1]", (int s) -> { withToString("int[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)(i + 1)); i -> (int)(i + 1));
@ -1126,6 +1130,46 @@ public class Int64VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(int a, int b) {
return a == b;
}
static boolean neq(int a, int b) {
return a != b;
}
static boolean lt(int a, int b) {
return a < b;
}
static boolean le(int a, int b) {
return a <= b;
}
static boolean gt(int a, int b) {
return a > b;
}
static boolean ge(int a, int b) {
return a >= b;
}
static boolean ult(int a, int b) {
return Integer.compareUnsigned(a, b) < 0;
}
static boolean ule(int a, int b) {
return Integer.compareUnsigned(a, b) <= 0;
}
static boolean ugt(int a, int b) {
return Integer.compareUnsigned(a, b) > 0;
}
static boolean uge(int a, int b) {
return Integer.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
IntVector three = IntVector.broadcast(SPECIES, (byte)-3); IntVector three = IntVector.broadcast(SPECIES, (byte)-3);
@ -3303,7 +3347,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3323,7 +3367,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3346,7 +3390,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3366,7 +3410,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3389,7 +3433,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3409,7 +3453,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3429,7 +3473,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3452,7 +3496,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3472,7 +3516,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3495,7 +3539,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3515,7 +3559,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3538,7 +3582,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3558,7 +3602,7 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3581,13 +3625,201 @@ public class Int64VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LTInt64VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LTInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GTInt64VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GTInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LEInt64VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LEInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GEInt64VectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GEInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider") @Test(dataProvider = "intCompareOpProvider")
static void LTInt64VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) { static void LTInt64VectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length()); int[] a = fa.apply(SPECIES.length());

View file

@ -968,4 +968,7 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -1008,6 +1008,10 @@ public class IntMaxVectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)i); i -> (int)i);
}), }),
withToString("int[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (int)(i - (s * BUFFER_REPS / 2)));
}),
withToString("int[i + 1]", (int s) -> { withToString("int[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (int)(i + 1)); i -> (int)(i + 1));
@ -1131,6 +1135,46 @@ public class IntMaxVectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(int a, int b) {
return a == b;
}
static boolean neq(int a, int b) {
return a != b;
}
static boolean lt(int a, int b) {
return a < b;
}
static boolean le(int a, int b) {
return a <= b;
}
static boolean gt(int a, int b) {
return a > b;
}
static boolean ge(int a, int b) {
return a >= b;
}
static boolean ult(int a, int b) {
return Integer.compareUnsigned(a, b) < 0;
}
static boolean ule(int a, int b) {
return Integer.compareUnsigned(a, b) <= 0;
}
static boolean ugt(int a, int b) {
return Integer.compareUnsigned(a, b) > 0;
}
static boolean uge(int a, int b) {
return Integer.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
IntVector three = IntVector.broadcast(SPECIES, (byte)-3); IntVector three = IntVector.broadcast(SPECIES, (byte)-3);
@ -3308,7 +3352,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3328,7 +3372,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3351,7 +3395,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3371,7 +3415,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3394,7 +3438,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3414,7 +3458,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3434,7 +3478,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3457,7 +3501,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3477,7 +3521,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3500,7 +3544,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3520,7 +3564,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3543,7 +3587,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3563,7 +3607,7 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3586,13 +3630,201 @@ public class IntMaxVectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LTIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GTIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_LEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_LEIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider")
static void UNSIGNED_GEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpMaskProvider")
static void UNSIGNED_GEIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
IntVector bv = IntVector.fromArray(SPECIES, b, i);
VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "intCompareOpProvider") @Test(dataProvider = "intCompareOpProvider")
static void LTIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) { static void LTIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
int[] a = fa.apply(SPECIES.length()); int[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Long128VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -966,8 +966,9 @@ public class Long128VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
long[] a = new long[l]; long[] a = new long[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (long)RAND.nextInt(m); a[i] = (long)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1028,6 +1029,10 @@ public class Long128VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (long)i); i -> (long)i);
}), }),
withToString("long[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (long)(i - (s * BUFFER_REPS / 2)));
}),
withToString("long[i + 1]", (int s) -> { withToString("long[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (long)(i + 1)); i -> (long)(i + 1));
@ -1147,6 +1152,46 @@ public class Long128VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(long a, long b) {
return a == b;
}
static boolean neq(long a, long b) {
return a != b;
}
static boolean lt(long a, long b) {
return a < b;
}
static boolean le(long a, long b) {
return a <= b;
}
static boolean gt(long a, long b) {
return a > b;
}
static boolean ge(long a, long b) {
return a >= b;
}
static boolean ult(long a, long b) {
return Long.compareUnsigned(a, b) < 0;
}
static boolean ule(long a, long b) {
return Long.compareUnsigned(a, b) <= 0;
}
static boolean ugt(long a, long b) {
return Long.compareUnsigned(a, b) > 0;
}
static boolean uge(long a, long b) {
return Long.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
LongVector three = LongVector.broadcast(SPECIES, (byte)-3); LongVector three = LongVector.broadcast(SPECIES, (byte)-3);
@ -3324,7 +3369,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3344,7 +3389,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3367,7 +3412,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3387,7 +3432,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3410,7 +3455,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3430,7 +3475,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3450,7 +3495,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3473,7 +3518,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3493,7 +3538,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3516,7 +3561,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3536,7 +3581,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3559,7 +3604,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3579,7 +3624,7 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3602,13 +3647,201 @@ public class Long128VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_LTLong128VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_LTLong128VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_GTLong128VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_GTLong128VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_LELong128VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_LELong128VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_GELong128VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_GELong128VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") @Test(dataProvider = "longCompareOpProvider")
static void LTLong128VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { static void LTLong128VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length()); long[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Long256VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

View file

@ -966,8 +966,9 @@ public class Long256VectorTests extends AbstractVectorTest {
static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of( static final List<BiFunction<Integer,Integer,long[]>> LONG_SHUFFLE_GENERATORS = List.of(
withToStringBi("shuffle[random]", (Integer l, Integer m) -> { withToStringBi("shuffle[random]", (Integer l, Integer m) -> {
long[] a = new long[l]; long[] a = new long[l];
int upper = m;
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
a[i] = (long)RAND.nextInt(m); a[i] = (long)RAND.nextInt(upper);
} }
return a; return a;
}) })
@ -1028,6 +1029,10 @@ public class Long256VectorTests extends AbstractVectorTest {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (long)i); i -> (long)i);
}), }),
withToString("long[i - length / 2]", (int s) -> {
return fill(s * BUFFER_REPS,
i -> (long)(i - (s * BUFFER_REPS / 2)));
}),
withToString("long[i + 1]", (int s) -> { withToString("long[i + 1]", (int s) -> {
return fill(s * BUFFER_REPS, return fill(s * BUFFER_REPS,
i -> (long)(i + 1)); i -> (long)(i + 1));
@ -1147,6 +1152,46 @@ public class Long256VectorTests extends AbstractVectorTest {
} }
} }
static boolean eq(long a, long b) {
return a == b;
}
static boolean neq(long a, long b) {
return a != b;
}
static boolean lt(long a, long b) {
return a < b;
}
static boolean le(long a, long b) {
return a <= b;
}
static boolean gt(long a, long b) {
return a > b;
}
static boolean ge(long a, long b) {
return a >= b;
}
static boolean ult(long a, long b) {
return Long.compareUnsigned(a, b) < 0;
}
static boolean ule(long a, long b) {
return Long.compareUnsigned(a, b) <= 0;
}
static boolean ugt(long a, long b) {
return Long.compareUnsigned(a, b) > 0;
}
static boolean uge(long a, long b) {
return Long.compareUnsigned(a, b) >= 0;
}
@Test @Test
static void smokeTest1() { static void smokeTest1() {
LongVector three = LongVector.broadcast(SPECIES, (byte)-3); LongVector three = LongVector.broadcast(SPECIES, (byte)-3);
@ -3324,7 +3369,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3344,7 +3389,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i + j]); Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3367,7 +3412,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
} }
} }
} }
@ -3387,7 +3432,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] > b[i + j]); Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3410,7 +3455,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] > b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
} }
} }
} }
@ -3430,7 +3475,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3450,7 +3495,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i + j]); Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3473,7 +3518,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
} }
} }
} }
@ -3493,7 +3538,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] != b[i + j]); Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3516,7 +3561,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] != b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
} }
} }
} }
@ -3536,7 +3581,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] <= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
} }
} }
} }
@ -3559,7 +3604,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] <= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
} }
} }
} }
@ -3579,7 +3624,7 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), a[i + j] >= b[i + j]); Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
} }
} }
} }
@ -3602,13 +3647,201 @@ public class Long256VectorTests extends AbstractVectorTest {
// Check results as part of computation. // Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) { for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] >= b[i + j])); Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
} }
} }
} }
} }
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_LTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_LTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_GTLong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_GTLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_LELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_LELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider")
static void UNSIGNED_GELong256VectorTests(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpMaskProvider")
static void UNSIGNED_GELong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<long[]> fb,
IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] b = fb.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
LongVector bv = LongVector.fromArray(SPECIES, b, i);
VectorMask<Long> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
}
}
}
}
@Test(dataProvider = "longCompareOpProvider") @Test(dataProvider = "longCompareOpProvider")
static void LTLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) { static void LTLong256VectorTestsBroadcastSmokeTest(IntFunction<long[]> fa, IntFunction<long[]> fb) {
long[] a = fa.apply(SPECIES.length()); long[] a = fa.apply(SPECIES.length());

View file

@ -959,4 +959,7 @@ public class Long512VectorLoadStoreTests extends AbstractVectorTest {
Assert.assertEquals(r, a); Assert.assertEquals(r, a);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show more