--- old/src/hotspot/cpu/x86/assembler_x86.cpp 2018-04-27 15:30:39.313585338 -0700 +++ new/src/hotspot/cpu/x86/assembler_x86.cpp 2018-04-27 15:30:39.017582615 -0700 @@ -1762,6 +1762,14 @@ emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::vcvtdq2pd(XMMRegister dst, XMMRegister src, int vector_len) { + assert(vector_len <= AVX_256bit ? VM_Version::supports_avx() : VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_F3, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE6); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); @@ -1770,6 +1778,14 @@ emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::vcvtdq2ps(XMMRegister dst, XMMRegister src, int vector_len) { + assert(vector_len <= AVX_256bit ? VM_Version::supports_avx() : VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); + emit_int8(0x5B); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -1884,7 +1900,6 @@ int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0x5A); emit_int8((unsigned char)(0xC0 | encode)); - } void Assembler::evcvtps2pd(XMMRegister dst, XMMRegister src, int vector_len) { @@ -1912,6 +1927,95 @@ emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::vcvtpd2ps(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == AVX_128bit || vector_len == AVX_256bit), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x5A); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evcvtpd2ps(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x5A); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evcvtqq2ps(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2 && VM_Version::supports_avx512dq(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x5B); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evcvtqq2pd(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2 && VM_Version::supports_avx512dq(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE6); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evpmovwb(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x30); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evpmovdw(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x33); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evpmovdb(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x31); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evpmovqd(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x35); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evpmovqb(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x32); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::evpmovqw(XMMRegister dst, XMMRegister src, int vector_len) { + assert(UseAVX > 2, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x34); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::pabsd(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_ssse3(), ""); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); @@ -3637,6 +3741,23 @@ emit_int8(imm8); } +void Assembler::vpermilps(XMMRegister dst, XMMRegister src, int imm8, int vector_len) { + assert(VM_Version::supports_avx(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8(0x04); + emit_int8(0xC0 | encode); + emit_int8(imm8); +} + +void Assembler::vpermpd(XMMRegister dst, XMMRegister src, int imm8, int vector_len) { + assert(VM_Version::supports_avx2(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8(0x01); + emit_int8(0xC0 | encode); + emit_int8(imm8); +} void Assembler::pause() { emit_int8((unsigned char)0xF3); @@ -4181,29 +4302,65 @@ } void Assembler::vpmovsxbd(XMMRegister dst, XMMRegister src, int vector_len) { - assert(vector_len > AVX_128bit ? VM_Version::supports_avx2() : VM_Version::supports_avx(), ""); - InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + vector_len == AVX_256bit ? VM_Version::supports_avx2() : + VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x21); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::vpmovsxbq(XMMRegister dst, XMMRegister src, int vector_len) { - assert(vector_len > AVX_128bit ? VM_Version::supports_avx2() : VM_Version::supports_avx(), ""); - InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + vector_len == AVX_256bit ? VM_Version::supports_avx2() : + VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x22); emit_int8((unsigned char)(0xC0 | encode)); } void Assembler::vpmovsxbw(XMMRegister dst, XMMRegister src, int vector_len) { - assert(vector_len > AVX_128bit ? VM_Version::supports_avx2() : VM_Version::supports_avx(), ""); - InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + vector_len == AVX_256bit ? VM_Version::supports_avx2() : + VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x20); emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::vpmovsxwd(XMMRegister dst, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + vector_len == AVX_256bit ? VM_Version::supports_avx2() : + VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x23); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::vpmovsxwq(XMMRegister dst, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + vector_len == AVX_256bit ? VM_Version::supports_avx2() : + VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x24); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::vpmovsxdq(XMMRegister dst, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + vector_len == AVX_256bit ? VM_Version::supports_avx2() : + VM_Version::supports_evex(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x25); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::evpmovwb(Address dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx512vlbw(), ""); assert(src != xnoreg, "sanity"); --- old/src/hotspot/cpu/x86/assembler_x86.hpp 2018-04-27 15:30:40.553596747 -0700 +++ new/src/hotspot/cpu/x86/assembler_x86.hpp 2018-04-27 15:30:40.217593655 -0700 @@ -1094,9 +1094,11 @@ // Convert Packed Signed Doubleword Integers to Packed Double-Precision Floating-Point Value void cvtdq2pd(XMMRegister dst, XMMRegister src); + void vcvtdq2pd(XMMRegister dst, XMMRegister src, int vector_len); // Convert Packed Signed Doubleword Integers to Packed Single-Precision Floating-Point Value void cvtdq2ps(XMMRegister dst, XMMRegister src); + void vcvtdq2ps(XMMRegister dst, XMMRegister src, int vector_len); // Convert Scalar Single-Precision Floating-Point Value to Scalar Double-Precision Floating-Point Value void cvtss2sd(XMMRegister dst, XMMRegister src); @@ -1111,11 +1113,26 @@ void cvttss2sil(Register dst, XMMRegister src); void cvttss2siq(Register dst, XMMRegister src); + // Convert vector double to int void cvttpd2dq(XMMRegister dst, XMMRegister src); // Convert vector float and double void vcvtps2pd(XMMRegister dst, XMMRegister src, int vector_len); void evcvtps2pd(XMMRegister dst, XMMRegister src, int vector_len); + void vcvtpd2ps(XMMRegister dst, XMMRegister src, int vector_len); + void evcvtpd2ps(XMMRegister dst, XMMRegister src, int vector_len); + + // Convert vector long to vector FP + void evcvtqq2ps(XMMRegister dst, XMMRegister src, int vector_len); + void evcvtqq2pd(XMMRegister dst, XMMRegister src, int vector_len); + + // Evex casts with truncation + void evpmovwb(XMMRegister dst, XMMRegister src, int vector_len); + void evpmovdw(XMMRegister dst, XMMRegister src, int vector_len); + void evpmovdb(XMMRegister dst, XMMRegister src, int vector_len); + void evpmovqd(XMMRegister dst, XMMRegister src, int vector_len); + void evpmovqb(XMMRegister dst, XMMRegister src, int vector_len); + void evpmovqw(XMMRegister dst, XMMRegister src, int vector_len); //Abs of packed Integer values void pabsb(XMMRegister dst, XMMRegister src); @@ -1621,6 +1638,8 @@ void vpermd(XMMRegister dst, XMMRegister nds, Address src); void vperm2i128(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8); void vperm2f128(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8); + void vpermilps(XMMRegister dst, XMMRegister src, int imm8, int vector_len); + void vpermpd(XMMRegister dst, XMMRegister src, int imm8, int vector_len); void pause(); @@ -1706,6 +1725,9 @@ void vpmovsxbd(XMMRegister dst, XMMRegister src, int vector_len); void vpmovsxbq(XMMRegister dst, XMMRegister src, int vector_len); void vpmovsxbw(XMMRegister dst, XMMRegister src, int vector_len); + void vpmovsxwd(XMMRegister dst, XMMRegister src, int vector_len); + void vpmovsxwq(XMMRegister dst, XMMRegister src, int vector_len); + void vpmovsxdq(XMMRegister dst, XMMRegister src, int vector_len); void evpmovwb(Address dst, XMMRegister src, int vector_len); void evpmovwb(Address dst, KRegister mask, XMMRegister src, int vector_len); --- old/src/hotspot/cpu/x86/macroAssembler_x86.cpp 2018-04-27 15:30:41.693607237 -0700 +++ new/src/hotspot/cpu/x86/macroAssembler_x86.cpp 2018-04-27 15:30:41.389604439 -0700 @@ -4442,12 +4442,12 @@ } } -void MacroAssembler::vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len) { +void MacroAssembler::vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register scratch_reg) { if (reachable(src)) { Assembler::vpand(dst, nds, as_Address(src), vector_len); } else { - lea(rscratch1, src); - Assembler::vpand(dst, nds, Address(rscratch1, 0), vector_len); + lea(scratch_reg, src); + Assembler::vpand(dst, nds, Address(scratch_reg, 0), vector_len); } } --- old/src/hotspot/cpu/x86/macroAssembler_x86.hpp 2018-04-27 15:30:42.869618057 -0700 +++ new/src/hotspot/cpu/x86/macroAssembler_x86.hpp 2018-04-27 15:30:42.569615296 -0700 @@ -1240,7 +1240,7 @@ void vpand(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vpand(dst, nds, src, vector_len); } void vpand(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vpand(dst, nds, src, vector_len); } - void vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len); + void vpand(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register scratch_reg); void vpbroadcastw(XMMRegister dst, XMMRegister src); --- old/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp 2018-04-27 15:30:44.005628509 -0700 +++ new/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp 2018-04-27 15:30:43.705625750 -0700 @@ -5112,7 +5112,13 @@ StubRoutines::x86::_vector_byte_bitset = generate_vector_fp_mask("vector_byte_bitset", 0x0101010101010101); StubRoutines::x86::_vector_long_perm_mask = generate_vector_custom_i32("vector_long_perm_mask", Assembler::AVX_512bit, 0, 2, 4, 6, 8, 10, 12, 14); - StubRoutines::x86::_vector_byte_saturation_mask = generate_vector_fp_mask("vector_byte_saturation_mask", 0x00ff00ff00ff00ff); + StubRoutines::x86::_vector_short_to_byte_mask = generate_vector_fp_mask("vector_short_to_byte_mask", 0x00ff00ff00ff00ff); + StubRoutines::x86::_vector_int_to_byte_mask = generate_vector_fp_mask("vector_int_to_byte_mask", 0x000000ff000000ff); + StubRoutines::x86::_vector_int_to_short_mask = generate_vector_fp_mask("vector_int_to_short_mask", 0x0000ffff0000ffff); + StubRoutines::x86::_vector_32_bit_mask = generate_vector_custom_i32("vector_32_bit_mask", Assembler::AVX_512bit, + 0xFFFFFFFF, 0, 0, 0); + StubRoutines::x86::_vector_64_bit_mask = generate_vector_custom_i32("vector_64_bit_mask", Assembler::AVX_512bit, + 0xFFFFFFFF, 0xFFFFFFFF, 0, 0); // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); --- old/src/hotspot/cpu/x86/stubRoutines_x86.hpp 2018-04-27 15:30:45.149639036 -0700 +++ new/src/hotspot/cpu/x86/stubRoutines_x86.hpp 2018-04-27 15:30:44.853636311 -0700 @@ -61,7 +61,11 @@ static address _vector_all_bits_set; static address _vector_byte_bitset; static address _vector_long_perm_mask; - static address _vector_byte_saturation_mask; + static address _vector_short_to_byte_mask; + static address _vector_int_to_byte_mask; + static address _vector_int_to_short_mask; + static address _vector_32_bit_mask; + static address _vector_64_bit_mask; public: @@ -133,8 +137,24 @@ return _vector_long_perm_mask; } - static address vector_byte_saturation_mask() { - return _vector_byte_saturation_mask; + static address vector_short_to_byte_mask() { + return _vector_short_to_byte_mask; + } + + static address vector_int_to_byte_mask() { + return _vector_int_to_byte_mask; + } + + static address vector_int_to_short_mask() { + return _vector_int_to_short_mask; + } + + static address vector_32_bit_mask() { + return _vector_32_bit_mask; + } + + static address vector_64_bit_mask() { + return _vector_64_bit_mask; } #else // !LP64 --- old/src/hotspot/cpu/x86/stubRoutines_x86_64.cpp 2018-04-27 15:30:46.265649303 -0700 +++ new/src/hotspot/cpu/x86/stubRoutines_x86_64.cpp 2018-04-27 15:30:45.965646543 -0700 @@ -49,4 +49,8 @@ address StubRoutines::x86::_vector_all_bits_set = NULL; address StubRoutines::x86::_vector_byte_bitset = NULL; address StubRoutines::x86::_vector_long_perm_mask = NULL; -address StubRoutines::x86::_vector_byte_saturation_mask = NULL; +address StubRoutines::x86::_vector_short_to_byte_mask = NULL; +address StubRoutines::x86::_vector_int_to_byte_mask = NULL; +address StubRoutines::x86::_vector_int_to_short_mask = NULL; +address StubRoutines::x86::_vector_32_bit_mask = NULL; +address StubRoutines::x86::_vector_64_bit_mask = NULL; --- old/src/hotspot/cpu/x86/x86.ad 2018-04-27 15:30:47.445660160 -0700 +++ new/src/hotspot/cpu/x86/x86.ad 2018-04-27 15:30:47.141657364 -0700 @@ -1215,7 +1215,11 @@ static address vector_all_bits_set() { return StubRoutines::x86::vector_all_bits_set(); } static address vector_byte_bitset() { return StubRoutines::x86::vector_byte_bitset(); } static address vector_long_perm_mask() { return StubRoutines::x86::vector_long_perm_mask(); } - static address vector_byte_saturationmask() { return StubRoutines::x86::vector_byte_saturation_mask(); } + static address vector_short_to_byte_mask() { return StubRoutines::x86::vector_short_to_byte_mask(); } + static address vector_int_to_byte_mask() { return StubRoutines::x86::vector_int_to_byte_mask(); } + static address vector_int_to_short_mask() { return StubRoutines::x86::vector_int_to_short_mask(); } + static address vector_32_bit_mask() { return StubRoutines::x86::vector_32_bit_mask(); } + static address vector_64_bit_mask() { return StubRoutines::x86::vector_64_bit_mask(); } #else static address float_signmask() { return (address)float_signmask_pool; } static address float_signflip() { return (address)float_signflip_pool; } @@ -1389,6 +1393,41 @@ else if (vlen == 1 || vlen == 2) { ret_value = false; } // Implementation limitation else if (size_in_bits == 512 && !VM_Version::supports_avx512bw()) { ret_value = false; } // Implementation limitation break; + case Op_VectorCastB2X: + if (UseAVX <= 0) { ret_value = false; } + else if (size_in_bits >= 256 && UseAVX < 2) { ret_value = false; } + break; + case Op_VectorCastS2X: + if (UseAVX <= 0) { ret_value = false; } + else if (is_integral_type(bt) && size_in_bits == 256 && UseAVX < 2) { ret_value = false; } + else if (is_integral_type(bt) && vlen * type2aelembytes(T_SHORT) * BitsPerByte == 256 && UseAVX < 2) { ret_value = false; } + break; + case Op_VectorCastI2X: + if (UseAVX <= 0) { ret_value = false; } + else if (is_integral_type(bt) && size_in_bits == 256 && UseAVX < 2) { ret_value = false; } + else if (is_integral_type(bt) && vlen * type2aelembytes(T_INT) * BitsPerByte == 256 && UseAVX < 2) { ret_value = false; } + break; + case Op_VectorCastL2X: + if (UseAVX <= 0) { ret_value = false; } + else if (is_integral_type(bt) && size_in_bits == 256 && UseAVX < 2) { ret_value = false; } + else if (is_integral_type(bt) && vlen * type2aelembytes(T_LONG) * BitsPerByte == 256 && UseAVX < 2) { ret_value = false; } + else if (!is_integral_type(bt) && !VM_Version::supports_avx512dq()) { ret_value = false; } + break; + case Op_VectorCastF2X: + // Casts from FP to integral types require special fixup logic not easily + // implementable with vectors. + if (UseAVX <= 0) { ret_value = false; } + else if (bt != T_DOUBLE) { ret_value = false; } // Implementation limitation + break; + case Op_VectorCastD2X: + // Casts from FP to integral types require special fixup logic not easily + // implementable with vectors. + if (UseAVX <= 0) { ret_value = false; } + else if (bt != T_FLOAT) { ret_value = false; } // Implementation limitation + break; + case Op_VectorReinterpret: + if (size_in_bits >= 256 && UseAVX < 2) { ret_value = false; } + break; default: break; } @@ -2822,56 +2861,80 @@ ins_pipe( pipe_slow ); %} -instruct reinterpretS2D(vecD dst, vecS src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); +instruct reinterpretS2D(vecD dst, vecS src, rRegL scratch) %{ + predicate(UseAVX == 0 && n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP dst, TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ - __ pxor($dst$$XMMRegister, $dst$$XMMRegister); - __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + __ movdqu($dst$$XMMRegister, ExternalAddress(vector_32_bit_mask()), $scratch$$Register); + __ pand($dst$$XMMRegister, $src$$XMMRegister); %} ins_pipe( pipe_slow ); %} -instruct reinterpretS2X(vecX dst, vecS src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); +instruct reinterpretS2D_avx(vecD dst, vecS src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->bottom_type()->is_vect()->length_in_bytes() == 8 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP dst, TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ - __ pxor($dst$$XMMRegister, $dst$$XMMRegister); - __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_32_bit_mask()), vector_len, $scratch$$Register); %} ins_pipe( pipe_slow ); %} -instruct reinterpretS2Y(vecY dst, vecS src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); +instruct reinterpretS2X(vecX dst, vecS src, rRegL scratch) %{ + predicate(UseAVX == 0 && n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP dst, TEMP scratch); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + __ movdqu($dst$$XMMRegister, ExternalAddress(vector_32_bit_mask()), $scratch$$Register); + __ pand($dst$$XMMRegister, $src$$XMMRegister); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretS2X_avx(vecX dst, vecS src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP scratch); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_32_bit_mask()), vector_len, $scratch$$Register); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretS2Y(vecY dst, vecS src, rRegL scratch) %{ + predicate(UseAVX >= 2 && n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ int vector_len = 1; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_32_bit_mask()), vector_len, $scratch$$Register); %} ins_pipe( pipe_slow ); %} -instruct reinterpretS2Z(vecZ dst, vecS src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); +instruct reinterpretS2Z(vecZ dst, vecS src, rRegL scratch) %{ + predicate(UseAVX > 2 && n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 4); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ int vector_len = 2; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_32_bit_mask()), vector_len, $scratch$$Register); %} ins_pipe( pipe_slow ); %} @@ -2901,43 +2964,54 @@ ins_pipe( pipe_slow ); %} -instruct reinterpretD2X(vecX dst, vecD src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); +instruct reinterpretD2X(vecX dst, vecD src, rRegL scratch) %{ + predicate(UseAVX == 0 && n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP dst, TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ - __ pxor($dst$$XMMRegister, $dst$$XMMRegister); - __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + __ movdqu($dst$$XMMRegister, ExternalAddress(vector_64_bit_mask()), $scratch$$Register); + __ pand($dst$$XMMRegister, $src$$XMMRegister); %} ins_pipe( pipe_slow ); %} -instruct reinterpretD2Y(vecY dst, vecD src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); +instruct reinterpretD2X_avx(vecX dst, vecD src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->bottom_type()->is_vect()->length_in_bytes() == 16 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP dst, TEMP scratch); + format %{ " # reinterpret $dst,$src" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_64_bit_mask()), vector_len, $scratch$$Register); + %} + ins_pipe( pipe_slow ); +%} + +instruct reinterpretD2Y(vecY dst, vecD src, rRegL scratch) %{ + predicate(UseAVX >= 2 && n->bottom_type()->is_vect()->length_in_bytes() == 32 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); + match(Set dst (VectorReinterpret src)); + ins_cost(125); + effect(TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ int vector_len = 1; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_64_bit_mask()), vector_len, $scratch$$Register); %} ins_pipe( pipe_slow ); %} -instruct reinterpretD2Z(vecZ dst, vecD src) %{ - predicate(n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); +instruct reinterpretD2Z(vecZ dst, vecD src, rRegL scratch) %{ + predicate(UseAVX > 2 && n->bottom_type()->is_vect()->length_in_bytes() == 64 && n->in(1)->bottom_type()->is_vect()->length_in_bytes() == 8); match(Set dst (VectorReinterpret src)); ins_cost(125); - effect(TEMP dst); + effect(TEMP scratch); format %{ " # reinterpret $dst,$src" %} ins_encode %{ int vector_len = 2; - __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_64_bit_mask()), vector_len, $scratch$$Register); %} ins_pipe( pipe_slow ); %} @@ -2990,7 +3064,7 @@ ins_encode %{ int vector_len = 1; __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); // just 128-bits need moved %} ins_pipe( pipe_slow ); %} @@ -3004,7 +3078,7 @@ ins_encode %{ int vector_len = 2; __ vpxor($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); - __ vmovdqu($dst$$XMMRegister, $src$$XMMRegister); + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); // just 128-bits need moved %} ins_pipe( pipe_slow ); %} @@ -9135,7 +9209,7 @@ __ pmovsxbw($tmp$$XMMRegister, $src1$$XMMRegister); __ pmovsxbw($tmp2$$XMMRegister, $src2$$XMMRegister); __ pmullw($tmp$$XMMRegister, $tmp2$$XMMRegister); - __ movdqu($tmp2$$XMMRegister, ExternalAddress(vector_byte_saturationmask())); + __ movdqu($tmp2$$XMMRegister, ExternalAddress(vector_short_to_byte_mask())); __ pand($tmp$$XMMRegister, $tmp2$$XMMRegister); __ packuswb($tmp$$XMMRegister, $tmp$$XMMRegister); __ movss($dst$$XMMRegister, $tmp$$XMMRegister); @@ -9158,7 +9232,7 @@ __ pmovsxbw($tmp$$XMMRegister, $src1$$XMMRegister); __ pmovsxbw($tmp2$$XMMRegister, $src2$$XMMRegister); __ pmullw($tmp$$XMMRegister, $tmp2$$XMMRegister); - __ movdqu($tmp2$$XMMRegister, ExternalAddress(vector_byte_saturationmask())); + __ movdqu($tmp2$$XMMRegister, ExternalAddress(vector_short_to_byte_mask())); __ pand($tmp$$XMMRegister, $tmp2$$XMMRegister); __ packuswb($tmp$$XMMRegister, $tmp$$XMMRegister); __ movsd($dst$$XMMRegister, $tmp$$XMMRegister); @@ -9192,7 +9266,7 @@ __ pmovsxbw($tmp2$$XMMRegister, $tmp2$$XMMRegister); __ pmovsxbw($tmp3$$XMMRegister, $tmp3$$XMMRegister); __ pmullw($tmp2$$XMMRegister, $tmp3$$XMMRegister); - __ movdqu($tmp3$$XMMRegister, ExternalAddress(vector_byte_saturationmask())); + __ movdqu($tmp3$$XMMRegister, ExternalAddress(vector_short_to_byte_mask())); __ pand($tmp$$XMMRegister, $tmp3$$XMMRegister); __ pand($tmp2$$XMMRegister, $tmp3$$XMMRegister); __ packuswb($tmp$$XMMRegister, $tmp2$$XMMRegister); @@ -9217,7 +9291,7 @@ __ vpmovsxbw($tmp$$XMMRegister, $src1$$XMMRegister, vector_len); __ vpmovsxbw($tmp2$$XMMRegister, $src2$$XMMRegister, vector_len); __ vpmullw($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); - __ vmovdqu($tmp2$$XMMRegister, ExternalAddress(vector_byte_saturationmask())); + __ vmovdqu($tmp2$$XMMRegister, ExternalAddress(vector_short_to_byte_mask())); __ vpand($tmp$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, vector_len); __ vextracti128_high($tmp2$$XMMRegister, $tmp$$XMMRegister); __ vpackuswb($dst$$XMMRegister, $tmp$$XMMRegister, $tmp2$$XMMRegister, 0); @@ -9253,7 +9327,7 @@ __ vpmovsxbw($tmp2$$XMMRegister, $src1$$XMMRegister, vector_len); __ vpmovsxbw($tmp3$$XMMRegister, $src2$$XMMRegister, vector_len); __ vpmullw($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister, vector_len); - __ vmovdqu($tmp3$$XMMRegister, ExternalAddress(vector_byte_saturationmask())); + __ vmovdqu($tmp3$$XMMRegister, ExternalAddress(vector_short_to_byte_mask())); __ vpbroadcastd($tmp3$$XMMRegister, $tmp3$$XMMRegister); __ vpand($tmp1$$XMMRegister, $tmp1$$XMMRegister, $tmp3$$XMMRegister, vector_len); __ vpand($tmp2$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister, vector_len); @@ -13894,9 +13968,821 @@ ins_pipe( pipe_slow ); %} +instruct vcvt4Bto4S_reg(vecD dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbw $dst,$src\t! convert 4B to 4S vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxbw($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Bto8S_reg(vecX dst, vecD src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbw $dst,$src\t! convert 8B to 8S vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxbw($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Bto16S_reg(vecY dst, vecX src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbw $dst,$src\t! convert 16B to 16S vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxbw($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt32Bto32S_reg(vecZ dst, vecY src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbw $dst,$src\t! convert 32B to 32S vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxbw($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Bto4I_reg(vecX dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbd $dst,$src\t! convert 4B to 4I vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Bto8I_reg(vecY dst, vecD src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbd $dst,$src\t! convert 8B to 8I vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Bto16I_reg(vecZ dst, vecX src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbd $dst,$src\t! convert 16B to 16I vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Bto4L_reg(vecY dst, vecS src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbq $dst,$src\t! convert 4B to 4L vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxbq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Bto8L_reg(vecZ dst, vecD src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbq $dst,$src\t! convert 8B to 8L vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxbq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Bto4F_reg(vecX dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 4B to 4F vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Bto8F_reg(vecY dst, vecD src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 8B to 8F vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Bto16F_reg(vecZ dst, vecX src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 16B to 16F vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Bto4D_reg(vecY dst, vecS src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbq $dst,$src\n\t" + "vcvtdq2pd $dst,$dst\t! convert 4B to 4D vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2pd($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Bto8D_reg(vecZ dst, vecD src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastB2X src)); + format %{ "vpmovsxbq $dst,$src\n\t" + "vcvtdq2pd $dst,$dst\t! convert 8B to 8D vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxbd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2pd($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Sto4B_reg(vecS dst, vecD src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + effect(TEMP scratch); + match(Set dst (VectorCastS2X src)); + format %{ "vpand $dst,$src,[0x00FF00FF00FF00FF]\n\t" + "vpackuswb $dst,$dst\t! convert 4S to 4B vector" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_short_to_byte_mask()), vector_len, $scratch$$Register); + __ vpackuswb($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Sto8B_reg(vecD dst, vecX src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + effect(TEMP scratch); + match(Set dst (VectorCastS2X src)); + format %{ "vpand $dst,$src,[0x00FF00FF00FF00FF]\n\t" + "vpackuswb $dst,$dst\t! convert 8S to 8B vector" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_short_to_byte_mask()), vector_len, $scratch$$Register); + __ vpackuswb($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Sto16B_reg(vecX dst, vecY src, vecY tmp, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + effect(TEMP scratch, TEMP tmp); + match(Set dst (VectorCastS2X src)); + format %{ "vpand $dst,$src,[0x00FF00FF00FF00FF]\n\t" + "vextracti128 $tmp,$dst,0x1\n\t" + "vpackuswb $dst,$dst,$tmp\t! convert 16S to 16B vector" %} + ins_encode %{ + int vector_len = 1; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_short_to_byte_mask()), vector_len, $scratch$$Register); + __ vextracti128($tmp$$XMMRegister, $dst$$XMMRegister, 0x1); + __ vpackuswb($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt32Sto32B_reg(vecY dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 32 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + match(Set dst (VectorCastS2X src)); + format %{ "evpmovwb $dst,$src\t! convert 32S to 32B vector" %} + ins_encode %{ + int vector_len = 2; + __ evpmovwb($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Sto2I_reg(vecD dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\t! convert 2S to 2I vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Sto4I_reg(vecX dst, vecD src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\t! convert 4S to 4I vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Sto8I_reg(vecY dst, vecX src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\t! convert 8S to 8I vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Sto16I_reg(vecZ dst, vecY src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\t! convert 16S to 16I vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Sto2L_reg(vecX dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwq $dst,$src\t! convert 2S to 2L vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxwq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Sto4L_reg(vecY dst, vecD src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwq $dst,$src\t! convert 4S to 4L vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxwq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Sto8L_reg(vecZ dst, vecX src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwq $dst,$src\t! convert 8S to 8L vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxwq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Sto2F_reg(vecD dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 2S to 2F vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Sto4F_reg(vecX dst, vecD src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 4S to 4F vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Sto8F_reg(vecY dst, vecX src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 8S to 8F vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Sto16F_reg(vecZ dst, vecY src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2ps $dst,$dst\t! convert 16S to 16F vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Sto2D_reg(vecX dst, vecS src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2pd $dst,$dst\t! convert 2S to 2D vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2pd($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Sto4D_reg(vecY dst, vecD src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2pd $dst,$dst\t! convert 4S to 4D vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2pd($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Sto8D_reg(vecZ dst, vecX src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastS2X src)); + format %{ "vpmovsxwd $dst,$src\n\t" + "vcvtdq2pd $dst,$dst\t! convert 8S to 8D vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxwd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtdq2pd($dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Ito4B_reg(vecS dst, vecX src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + effect(TEMP scratch); + match(Set dst (VectorCastI2X src)); + format %{ "vpand $dst,$src,[0x000000FF000000FF]\n\t" + "vpackusdw $dst,$dst\n\t" + "vpackuswb $dst,$dst\t! convert 4I to 4B vector" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_int_to_byte_mask()), vector_len, $scratch$$Register); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vpackuswb($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Ito8B_reg(vecD dst, vecY src, vecY tmp, rRegL scratch) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + effect(TEMP scratch, TEMP tmp); + match(Set dst (VectorCastI2X src)); + format %{ "vpand $dst,$src,[0x000000FF000000FF]\n\t" + "vextracti128 $tmp,$dst,0x1\n\t" + "vpackusdw $dst,$dst,$tmp\n\t" + "vpackuswb $dst,$dst\t! convert 8I to 8B vector" %} + ins_encode %{ + int vector_len = 1; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_int_to_byte_mask()), vector_len, $scratch$$Register); + __ vextracti128($tmp$$XMMRegister, $dst$$XMMRegister, 0x1); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister, vector_len); + __ vpackuswb($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, 0); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Ito16B_reg(vecX dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + match(Set dst (VectorCastI2X src)); + format %{ "evpmovdb $dst,$src\t! convert 16I to 16B vector" %} + ins_encode %{ + int vector_len = 2; + __ evpmovdb($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Ito2S_reg(vecS dst, vecD src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + effect(TEMP scratch); + match(Set dst (VectorCastI2X src)); + format %{ "vpand $dst,$src,[0x0000FFFF0000FFFF]\n\t" + "vpackusdw $dst,$dst\t! convert 2I to 2S vector" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_int_to_short_mask()), vector_len, $scratch$$Register); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Ito4S_reg(vecD dst, vecX src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + effect(TEMP scratch); + match(Set dst (VectorCastI2X src)); + format %{ "vpand $dst,$src,[0x0000FFFF0000FFFF]\n\t" + "vpackusdw $dst,$dst\t! convert 4I to 4S vector" %} + ins_encode %{ + int vector_len = 0; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_int_to_short_mask()), vector_len, $scratch$$Register); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Ito8S_reg(vecX dst, vecY src, vecY tmp, rRegL scratch) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + effect(TEMP scratch, TEMP tmp); + match(Set dst (VectorCastI2X src)); + format %{ "vpand $dst,$src,[0x0000FFFF0000FFFF]\n\t" + "vextracti128 $tmp,$dst,0x1\n\t" + "vpackusdw $dst,$dst,$tmp\t! convert 8I to 8S vector" %} + ins_encode %{ + int vector_len = 1; + __ vpand($dst$$XMMRegister, $src$$XMMRegister, ExternalAddress(vector_int_to_short_mask()), vector_len, $scratch$$Register); + __ vextracti128($tmp$$XMMRegister, $dst$$XMMRegister, 0x1); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $tmp$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Ito16S_reg(vecY dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastI2X src)); + format %{ "evpmovdw $dst,$src\t! convert 16I to 16S vector" %} + ins_encode %{ + int vector_len = 2; + __ evpmovdw($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Ito2L_reg(vecX dst, vecD src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastI2X src)); + format %{ "vpmovsxdq $dst,$src\t! convert 2I to 2L vector" %} + ins_encode %{ + int vector_len = 0; + __ vpmovsxdq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Ito4L_reg(vecY dst, vecX src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastI2X src)); + format %{ "vpmovsxdq $dst,$src\t! convert 4I to 4L vector" %} + ins_encode %{ + int vector_len = 1; + __ vpmovsxdq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Ito8L_reg(vecZ dst, vecY src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_LONG); + match(Set dst (VectorCastI2X src)); + format %{ "vpmovsxdq $dst,$src\t! convert 8I to 8L vector" %} + ins_encode %{ + int vector_len = 2; + __ vpmovsxdq($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Ito2F_reg(vecD dst, vecD src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2ps $dst,$src\t! convert 2I to 2F vector" %} + ins_encode %{ + int vector_len = 0; + __ vcvtdq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Ito4F_reg(vecX dst, vecX src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2ps $dst,$src\t! convert 4I to 4F vector" %} + ins_encode %{ + int vector_len = 0; + __ vcvtdq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Ito8F_reg(vecY dst, vecY src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2ps $dst,$src\t! convert 8I to 8F vector" %} + ins_encode %{ + int vector_len = 1; + __ vcvtdq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt16Ito16F_reg(vecY dst, vecY src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 16 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2ps $dst,$src\t! convert 16I to 16F vector" %} + ins_encode %{ + int vector_len = 2; + __ vcvtdq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Ito2D_reg(vecX dst, vecD src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2pd $dst,$src\t! convert 2I to 2D vector" %} + ins_encode %{ + int vector_len = 0; + __ vcvtdq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Ito4D_reg(vecY dst, vecX src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2pd $dst,$src\t! convert 4I to 4D vector" %} + ins_encode %{ + int vector_len = 1; + __ vcvtdq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Ito8D_reg(vecZ dst, vecY src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastI2X src)); + format %{ "vcvtdq2pd $dst,$src\t! convert 8I to 8D vector" %} + ins_encode %{ + int vector_len = 2; + __ vcvtdq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Lto4B_reg(vecS dst, vecY src, rRegL scratch) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + match(Set dst (VectorCastL2X src)); + effect(TEMP scratch); + format %{ "vpermilps $dst,$src,8\n\t" + "vpermpd $dst,$dst,8\n\t" + "vpand $dst,$dst,[0x000000FF000000FF]\n\t" + "vpackusdw $dst,$dst\n\t" + "vpackuswb $dst,$dst\t! convert 4L to 4B vector" %} + ins_encode %{ + int vector_len = 1; + __ vpermilps($dst$$XMMRegister, $src$$XMMRegister, 8, vector_len); + __ vpermpd($dst$$XMMRegister, $dst$$XMMRegister, 8, vector_len); + // Since cast to int has been done, do rest of operations in 128. + vector_len = 0; + __ vpand($dst$$XMMRegister, $dst$$XMMRegister, ExternalAddress(vector_int_to_byte_mask()), vector_len, $scratch$$Register); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + __ vpackuswb($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Lto8B_reg(vecD dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_BYTE); + match(Set dst (VectorCastL2X src)); + format %{ "evpmovqb $dst,$src\t! convert 8L to 8B vector" %} + ins_encode %{ + int vector_len = 2; + __ evpmovqb($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Lto2S_reg(vecS dst, vecX src, rRegL scratch) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastL2X src)); + effect(TEMP scratch); + format %{ "vpshufd $dst,$src,8\n\t" + "vpand $dst,$dst,[0x0000FFFF0000FFFF]\n\t" + "vpackusdw $dst,$dst\t! convert 2L to 2S vector" %} + ins_encode %{ + int vector_len = 0; + __ vpshufd($dst$$XMMRegister, $src$$XMMRegister, 8, vector_len); + __ vpand($dst$$XMMRegister, $dst$$XMMRegister, ExternalAddress(vector_int_to_short_mask()), vector_len, $scratch$$Register); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Lto4S_reg(vecD dst, vecY src, rRegL scratch) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastL2X src)); + effect(TEMP scratch); + format %{ "vpermilps $dst,$src,8\n\t" + "vpermpd $dst,$dst,8\n\t" + "vpand $dst,$dst,[0x0000FFFF0000FFFF]\n\t" + "vpackusdw $dst,$dst\t! convert 4L to 4S vector" %} + ins_encode %{ + int vector_len = 1; + __ vpermilps($dst$$XMMRegister, $src$$XMMRegister, 8, vector_len); + __ vpermpd($dst$$XMMRegister, $dst$$XMMRegister, 8, vector_len); + // Since cast to int has been done, do rest of operations in 128. + vector_len = 0; + __ vpand($dst$$XMMRegister, $dst$$XMMRegister, ExternalAddress(vector_int_to_short_mask()), vector_len, $scratch$$Register); + __ vpackusdw($dst$$XMMRegister, $dst$$XMMRegister, $dst$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Lto8S_reg(vecX dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_SHORT); + match(Set dst (VectorCastL2X src)); + format %{ "evpmovqw $dst,$src\t! convert 8L to 8S vector" %} + ins_encode %{ + int vector_len = 2; + __ evpmovqw($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt1Lto1I_reg(vecS dst, vecD src) %{ + predicate(n->as_Vector()->length() == 1 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastL2X src)); + format %{ "movdqu $dst,$src\t! convert 1L to 1I vector" %} + ins_encode %{ + // If register is the same, then move is not needed. + if ($dst$$XMMRegister != $src$$XMMRegister) { + __ movdqu($dst$$XMMRegister, $src$$XMMRegister); + } + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Lto2I_reg(vecD dst, vecX src) %{ + predicate(UseAVX == 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastL2X src)); + format %{ "pshufd $dst,$src,8\t! convert 2L to 2I vector" %} + ins_encode %{ + __ pshufd($dst$$XMMRegister, $src$$XMMRegister, 8); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Lto2I_reg_avx(vecD dst, vecX src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastL2X src)); + format %{ "vpshufd $dst,$src,8\t! convert 2L to 2I vector" %} + ins_encode %{ + int vector_len = 0; + __ vpshufd($dst$$XMMRegister, $src$$XMMRegister, 8, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Lto4I_reg(vecX dst, vecY src) %{ + predicate(UseAVX >= 2 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastL2X src)); + format %{ "vpermilps $dst,$src,8\n\t" + "vpermpd $dst,$dst,8\t! convert 4L to 4I vector" %} + ins_encode %{ + int vector_len = 1; + __ vpermilps($dst$$XMMRegister, $src$$XMMRegister, 8, vector_len); + __ vpermpd($dst$$XMMRegister, $dst$$XMMRegister, 8, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Lto8I_reg(vecY dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_INT); + match(Set dst (VectorCastL2X src)); + format %{ "evpmovqd $dst,$src\t! convert 8L to 8I vector" %} + ins_encode %{ + int vector_len = 2; + __ evpmovqd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Lto2F_reg(vecD dst, vecX src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2ps $dst,$src\t! convert 2L to 2F vector" %} + ins_encode %{ + int vector_len = 0; + __ evcvtqq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Lto4F_reg(vecX dst, vecY src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2ps $dst,$src\t! convert 4L to 4F vector" %} + ins_encode %{ + int vector_len = 1; + __ evcvtqq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Lto8F_reg(vecY dst, vecZ src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2ps $dst,$src\t! convert 8L to 8F vector" %} + ins_encode %{ + int vector_len = 2; + __ evcvtqq2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt1Lto1D_reg(vecD dst, vecD src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 1 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2pd $dst,$src\t! convert 1L to 1D vector" %} + ins_encode %{ + int vector_len = 0; + __ evcvtqq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Lto2D_reg(vecX dst, vecX src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2pd $dst,$src\t! convert 2L to 2D vector" %} + ins_encode %{ + int vector_len = 0; + __ evcvtqq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Lto4D_reg(vecY dst, vecY src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2pd $dst,$src\t! convert 4L to 4D vector" %} + ins_encode %{ + int vector_len = 1; + __ evcvtqq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt8Lto8D_reg(vecZ dst, vecZ src) %{ + predicate(UseAVX > 2 && VM_Version::supports_avx512dq() && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastL2X src)); + format %{ "vcvtqq2pd $dst,$src\t! convert 8L to 8D vector" %} + ins_encode %{ + int vector_len = 2; + __ evcvtqq2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + instruct vcvt2Fto2D_reg(vecX dst, vecD src) %{ - predicate(UseAVX > 0 && n->as_Vector()->length_in_bytes() == 16); - match(Set dst (ConvertVF2VD src)); + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastF2X src)); format %{ "vcvtps2pd $dst,$src\t! convert 2F to 2D vector" %} ins_encode %{ int vector_len = 0; @@ -13906,8 +14792,8 @@ %} instruct vcvt4Fto4D_reg(vecY dst, vecX src) %{ - predicate(UseAVX > 0 && n->as_Vector()->length_in_bytes() == 32); - match(Set dst (ConvertVF2VD src)); + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastF2X src)); format %{ "vcvtps2pd $dst,$src\t! convert 4F to 4D vector" %} ins_encode %{ int vector_len = 1; @@ -13916,24 +14802,46 @@ ins_pipe( pipe_slow ); %} -instruct vcvt8Fto4D_reg(vecY dst, vecY src) %{ - predicate(UseAVX > 0 && n->as_Vector()->length_in_bytes() == 32); - match(Set dst (ConvertVF2VD src)); - format %{ "vcvtps2pd $dst,$src\t! convert 8F to 4D vector" %} +instruct vcvt8Fto8D_reg(vecZ dst, vecY src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE); + match(Set dst (VectorCastF2X src)); + format %{ "evcvtps2pd $dst,$src\t! convert 8F to 8D vector" %} + ins_encode %{ + int vector_len = 2; + __ evcvtps2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt2Dto2F_reg(vecD dst, vecX src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 2 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastD2X src)); + format %{ "vcvtpd2ps $dst,$src\t! convert 2D to 2F vector" %} + ins_encode %{ + int vector_len = 0; + __ vcvtpd2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + +instruct vcvt4Dto4F_reg(vecX dst, vecY src) %{ + predicate(UseAVX > 0 && n->as_Vector()->length() == 4 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastD2X src)); + format %{ "vcvtpd2ps $dst,$src\t! convert 4D to 4F vector" %} ins_encode %{ int vector_len = 1; - __ vcvtps2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ vcvtpd2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} -instruct vcvt8Fto8D_reg(vecZ dst, vecY src) %{ - predicate(UseAVX > 2 && n->as_Vector()->length_in_bytes() == 64); - match(Set dst (ConvertVF2VD src)); - format %{ "evcvtps2pd $dst,$src\t! convert 8F to 8D vector" %} +instruct vcvt8Dto8F_reg(vecY dst, vecZ src) %{ + predicate(UseAVX > 2 && n->as_Vector()->length() == 8 && n->bottom_type()->is_vect()->element_basic_type() == T_FLOAT); + match(Set dst (VectorCastD2X src)); + format %{ "evcvtpd2ps $dst,$src\t! convert 8D to 8F vector" %} ins_encode %{ int vector_len = 2; - __ evcvtps2pd($dst$$XMMRegister, $src$$XMMRegister, vector_len); + __ evcvtpd2ps($dst$$XMMRegister, $src$$XMMRegister, vector_len); %} ins_pipe( pipe_slow ); %} --- old/src/hotspot/share/adlc/formssel.cpp 2018-04-27 15:30:48.725671939 -0700 +++ new/src/hotspot/share/adlc/formssel.cpp 2018-04-27 15:30:48.421669141 -0700 @@ -4189,8 +4189,9 @@ "ReplicateB","ReplicateS","ReplicateI","ReplicateL","ReplicateF","ReplicateD", "LoadVector","StoreVector", "VectorLoadMask", "VectorStoreMask", "VectorBlend", - "VectorMaskWrapper", "VectorMaskCmp", - "ConvertVF2VD", "VectorReinterpret", + "VectorCastB2X", "VectorCastS2X", "VectorCastI2X", + "VectorCastL2X", "VectorCastF2X", "VectorCastD2X", + "VectorMaskWrapper", "VectorMaskCmp", "VectorReinterpret", "FmaVD", "FmaVF","PopCountVI", // Next are not supported currently. "PackB","PackS","PackI","PackL","PackF","PackD","Pack2L","Pack2D", --- old/src/hotspot/share/classfile/vmSymbols.hpp 2018-04-27 15:30:49.901682758 -0700 +++ new/src/hotspot/share/classfile/vmSymbols.hpp 2018-04-27 15:30:49.601679998 -0700 @@ -1487,11 +1487,16 @@ "Ljdk/incubator/vector/VectorIntrinsics$VectorBroadcastIntOp;)Ljdk/incubator/vector/Vector;") \ do_name(vector_broadcast_int_name, "broadcastInt") \ \ - do_intrinsic(_VectorReinterpret, jdk_incubator_vector_VectorIntrinsics, vector_reinterpret_name, vector_reinterpret_sig, F_S) \ - do_signature(vector_reinterpret_sig, "(Ljava/lang/Class;Ljava/lang/Class;I" \ - "Ljava/lang/Class;ILjava/lang/Object;" \ - "Ljdk/incubator/vector/VectorIntrinsics$VectorReinterpretOp;)Ljava/lang/Object;") \ - do_name(vector_reinterpret_name, "reinterpret") \ + do_intrinsic(_VectorReinterpret, jdk_incubator_vector_VectorIntrinsics, vector_reinterpret_name, vector_reinterpret_sig, F_S) \ + do_signature(vector_reinterpret_sig, "(Ljava/lang/Class;Ljava/lang/Class;I" \ + "Ljava/lang/Class;ILjava/lang/Object;" \ + "Ljdk/incubator/vector/VectorIntrinsics$VectorReinterpretOp;)Ljava/lang/Object;") \ + do_name(vector_reinterpret_name, "reinterpret") \ + \ + do_intrinsic(_VectorCast, jdk_incubator_vector_VectorIntrinsics, Class_cast_name, vector_cast_sig, F_S) \ + do_signature(vector_cast_sig, "(Ljava/lang/Class;Ljava/lang/Class;I" \ + "Ljava/lang/Class;ILjava/lang/Object;" \ + "Ljdk/incubator/vector/VectorIntrinsics$VectorCastOp;)Ljava/lang/Object;") \ \ do_intrinsic(_VectorRebox, jdk_incubator_vector_VectorIntrinsics, vector_rebox_name, vector_rebox_sig, F_S) \ do_alias(vector_rebox_sig, object_object_signature) \ @@ -1683,7 +1688,7 @@ #undef VM_INTRINSIC_ENUM ID_LIMIT, - LAST_COMPILER_INLINE = _VectorReinterpret, + LAST_COMPILER_INLINE = _VectorCast, FIRST_VECTOR_API = _VectorUnaryOp, LAST_VECTOR_API = _VectorRebox, FIRST_MH_SIG_POLY = _invokeGeneric, --- old/src/hotspot/share/opto/classes.hpp 2018-04-27 15:30:51.013692990 -0700 +++ new/src/hotspot/share/opto/classes.hpp 2018-04-27 15:30:50.717690267 -0700 @@ -388,7 +388,6 @@ macro(ExtractL) macro(ExtractF) macro(ExtractD) -macro(ConvertVF2VD) macro(VectorBox) macro(VectorBoxAllocate) macro(VectorUnbox) @@ -399,3 +398,9 @@ macro(VectorLoadMask) macro(VectorStoreMask) macro(VectorReinterpret) +macro(VectorCastB2X) +macro(VectorCastS2X) +macro(VectorCastI2X) +macro(VectorCastL2X) +macro(VectorCastF2X) +macro(VectorCastD2X) --- old/src/hotspot/share/opto/library_call.cpp 2018-04-27 15:30:52.137703332 -0700 +++ new/src/hotspot/share/opto/library_call.cpp 2018-04-27 15:30:51.829700498 -0700 @@ -340,7 +340,7 @@ bool inline_vector_blend(); bool inline_vector_compare(); bool inline_vector_broadcast_int(); - bool inline_vector_reinterpret(); + bool inline_vector_cast_reinterpret(bool is_cast); Node* box_vector(Node* in, const TypeInstPtr* vbox_type, BasicType bt, int num_elem); Node* unbox_vector(Node* in, const TypeInstPtr* vbox_type, BasicType bt, int num_elem); Node* shift_count(Node* cnt, int shift_op, BasicType bt, int num_elem); @@ -910,7 +910,9 @@ case vmIntrinsics::_VectorBroadcastInt: return inline_vector_broadcast_int(); case vmIntrinsics::_VectorReinterpret: - return inline_vector_reinterpret(); + return inline_vector_cast_reinterpret(/*is_cast*/ false); + case vmIntrinsics::_VectorCast: + return inline_vector_cast_reinterpret(/*is_cast*/ true); default: // If you get here, it may be that someone has added a new intrinsic @@ -7716,7 +7718,7 @@ return true; } -bool LibraryCallKit::inline_vector_reinterpret() { +bool LibraryCallKit::inline_vector_cast_reinterpret(bool is_cast) { const TypeInstPtr* vector_klass_from = gvn().type(argument(0))->is_instptr(); const TypeInstPtr* elem_klass_from = gvn().type(argument(1))->is_instptr(); const TypeInt* vlen_from = gvn().type(argument(2))->is_int(); @@ -7760,7 +7762,8 @@ elem_bt_to = getMaskBasicType(elem_bt_to); } - // Check whether we can unbox to appropriate size. + // Check whether we can unbox to appropriate size. Even with casting, checking for reinterpret is needed + // since we may need to change size. if (!arch_supports_vector(Op_VectorReinterpret, num_elem_from, elem_bt_from, @@ -7776,6 +7779,46 @@ return false; } + // At this point, we know that both input and output vector registers are supported + // by the architecture. Next check if the casted type is simply to same type - which means + // that it is actually a resize and not a cast. + if (is_cast && elem_bt_from == elem_bt_to) { + is_cast = false; + } + + int cast_vopc = 0; + if (is_cast) { + assert(!is_mask, "masks cannot be casted"); + switch (elem_bt_from) { + case T_BYTE: + cast_vopc = Op_VectorCastB2X; + break; + case T_SHORT: + cast_vopc = Op_VectorCastS2X; + break; + case T_INT: + cast_vopc = Op_VectorCastI2X; + break; + case T_LONG: + cast_vopc = Op_VectorCastL2X; + break; + case T_FLOAT: + cast_vopc = Op_VectorCastF2X; + break; + case T_DOUBLE: + cast_vopc = Op_VectorCastD2X; + break; + default: + Unimplemented(); + } + assert(cast_vopc != 0, "need to find vector cast operand"); + + // Make sure that cast is implemented to particular type/size combination. + if (!arch_supports_vector(cast_vopc, num_elem_to, elem_bt_to, VecMaskNotUsed)) { + return false; + } + } + const TypeInstPtr* vbox_type_from = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass_from); Node* opd1 = unbox_vector(argument(5), vbox_type_from, elem_bt_from, num_elem_from); @@ -7783,20 +7826,61 @@ return false; } - // Can assert when Phi merges vectors of different types: - // # Internal Error (/Users/vlivanov/ws/jdk/panama-dev/open/src/hotspot/share/opto/type.cpp:2291), pid=67536, tid=14083 - // # Error: assert(length() == v->length()) failed const TypeVect* src_type = TypeVect::make(elem_bt_from, num_elem_from); const TypeVect* dst_type = TypeVect::make(elem_bt_to, num_elem_to); + Node* op = opd1; - if (Type::cmp(src_type, dst_type) != 0) { + if (is_cast) { + if (num_elem_from < num_elem_to) { + // Since input and output number of elements are not consistent, we need to make sure we + // properly size. Thus, first make a cast that retains the number of elements from source. + // In case the size exceeds the arch size, we do the minimum. + int num_elem_for_cast = MIN2(num_elem_from, Matcher::max_vector_size(elem_bt_to)); + + // It is possible that arch does not support this intermediate vector size + // TODO More complex logic required here to handle this corner case for the sizes. + if (!arch_supports_vector(cast_vopc, num_elem_for_cast, elem_bt_to, VecMaskNotUsed)) { + return false; + } + + op = _gvn.transform(VectorNode::make(cast_vopc, op, NULL, num_elem_for_cast, elem_bt_to)); + // Now ensure that the destination gets properly resized to needed size. + op = _gvn.transform(new VectorReinterpretNode(op, op->bottom_type()->is_vect(), dst_type)); + } else if (num_elem_from > num_elem_to) { + // Since number elements from input is larger than output, simply reduce size of input (we are supposed to + // drop top elements anyway). + int num_elem_for_resize = MAX2(num_elem_to, Matcher::min_vector_size(elem_bt_to)); + + // It is possible that arch does not support this intermediate vector size + // TODO More complex logic required here to handle this corner case for the sizes. + if (!arch_supports_vector(Op_VectorReinterpret, + num_elem_for_resize, + elem_bt_from, + VecMaskNotUsed)) { + return false; + } + + op = _gvn.transform(new VectorReinterpretNode(op, + src_type, + TypeVect::make(elem_bt_from, + num_elem_for_resize))); + op = _gvn.transform(VectorNode::make(cast_vopc, op, NULL, num_elem_to, elem_bt_to)); + } else { + // Since input and output number of elements match, and since we know this vector size is + // supported, simply do a cast with no resize needed. + op = _gvn.transform(VectorNode::make(cast_vopc, op, NULL, num_elem_to, elem_bt_to)); + } + } else if (Type::cmp(src_type, dst_type) != 0) { + assert(!is_cast, "must be reinterpret"); op = _gvn.transform(new VectorReinterpretNode(op, src_type, dst_type)); } + ciKlass* vbox_klass_to = get_exact_klass_for_vector_box(vbox_klass_from, elem_type_to->basic_type(), num_elem_to, is_mask ? VECAPI_MASK : VECAPI_VECTOR); const TypeInstPtr* vbox_type_to = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass_to); Node* vbox = box_vector(op, vbox_type_to, elem_bt_to, num_elem_to); set_vector_result(vbox); + C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem_to * type2aelembytes(elem_bt_to)))); return true; } --- old/src/hotspot/share/opto/vectornode.cpp 2018-04-27 15:30:53.317714189 -0700 +++ new/src/hotspot/share/opto/vectornode.cpp 2018-04-27 15:30:53.021711465 -0700 @@ -295,6 +295,16 @@ case Op_AndV: case Op_OrV: case Op_XorV: + case Op_VectorBlend: + case Op_VectorReinterpret: + case Op_VectorTest: + case Op_VectorMaskCmp: + case Op_VectorCastB2X: + case Op_VectorCastS2X: + case Op_VectorCastI2X: + case Op_VectorCastL2X: + case Op_VectorCastF2X: + case Op_VectorCastD2X: // When op is already vectorized, return that directly. return sopc; @@ -483,11 +493,14 @@ case Op_AndV: return new AndVNode(n1, n2, vt); case Op_OrV: return new OrVNode (n1, n2, vt); case Op_XorV: return new XorVNode(n1, n2, vt); - - case Op_ConvertVF2VD: - if (bt == T_DOUBLE) { - return new ConvertVF2VDNode(n1, vt); - } + + case Op_VectorCastB2X: return new VectorCastB2XNode(n1, vt); + case Op_VectorCastS2X: return new VectorCastS2XNode(n1, vt); + case Op_VectorCastI2X: return new VectorCastI2XNode(n1, vt); + case Op_VectorCastL2X: return new VectorCastL2XNode(n1, vt); + case Op_VectorCastF2X: return new VectorCastF2XNode(n1, vt); + case Op_VectorCastD2X: return new VectorCastD2XNode(n1, vt); + default: fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); return NULL; --- old/src/hotspot/share/opto/vectornode.hpp 2018-04-27 15:30:54.429724421 -0700 +++ new/src/hotspot/share/opto/vectornode.hpp 2018-04-27 15:30:54.129721661 -0700 @@ -984,13 +984,6 @@ virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; } }; -// Type conversion nodes -class ConvertVF2VDNode : public VectorNode { - public: - ConvertVF2VDNode(Node* in, const TypeVect* vt) : VectorNode(in,vt) {} - virtual int Opcode() const; -}; - class VectorBoxNode : public Node { private: const TypeInstPtr* const _box_type; @@ -1177,4 +1170,52 @@ virtual int Opcode() const; }; +class VectorCastB2XNode : public VectorNode { +public: + VectorCastB2XNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { + assert(in->bottom_type()->is_vect()->element_basic_type() == T_BYTE, "must be byte"); + } + virtual int Opcode() const; +}; + +class VectorCastS2XNode : public VectorNode { +public: + VectorCastS2XNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { + assert(in->bottom_type()->is_vect()->element_basic_type() == T_SHORT, "must be short"); + } + virtual int Opcode() const; +}; + +class VectorCastI2XNode : public VectorNode { +public: + VectorCastI2XNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { + assert(in->bottom_type()->is_vect()->element_basic_type() == T_INT, "must be int"); + } + virtual int Opcode() const; +}; + +class VectorCastL2XNode : public VectorNode { +public: + VectorCastL2XNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { + assert(in->bottom_type()->is_vect()->element_basic_type() == T_LONG, "must be long"); + } + virtual int Opcode() const; +}; + +class VectorCastF2XNode : public VectorNode { +public: + VectorCastF2XNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { + assert(in->bottom_type()->is_vect()->element_basic_type() == T_FLOAT, "must be float"); + } + virtual int Opcode() const; +}; + +class VectorCastD2XNode : public VectorNode { +public: + VectorCastD2XNode(Node* in, const TypeVect* vt) : VectorNode(in, vt) { + assert(in->bottom_type()->is_vect()->element_basic_type() == T_DOUBLE, "must be double"); + } + virtual int Opcode() const; +}; + #endif // SHARE_VM_OPTO_VECTORNODE_HPP --- old/src/hotspot/share/runtime/vmStructs.cpp 2018-04-27 15:30:55.533734579 -0700 +++ new/src/hotspot/share/runtime/vmStructs.cpp 2018-04-27 15:30:55.237731855 -0700 @@ -2075,7 +2075,12 @@ declare_c2_type(VectorBlendNode, VectorNode) \ declare_c2_type(VectorMaskWrapperNode, VectorNode) \ declare_c2_type(VectorMaskCmpNode, VectorNode) \ - declare_c2_type(ConvertVF2VDNode, VectorNode) \ + declare_c2_type(VectorCastB2XNode, VectorNode) \ + declare_c2_type(VectorCastS2XNode, VectorNode) \ + declare_c2_type(VectorCastI2XNode, VectorNode) \ + declare_c2_type(VectorCastL2XNode, VectorNode) \ + declare_c2_type(VectorCastF2XNode, VectorNode) \ + declare_c2_type(VectorCastD2XNode, VectorNode) \ declare_c2_type(VectorUnboxNode, VectorNode) \ declare_c2_type(VectorReinterpretNode, VectorNode) \ declare_c2_type(VectorBoxNode, Node) \ --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java 2018-04-27 15:30:56.649744846 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java 2018-04-27 15:30:56.353742124 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Byte128Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte128Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte128Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte128Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte128Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte128Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte128Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Byte128Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java 2018-04-27 15:30:57.749754968 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java 2018-04-27 15:30:57.449752208 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Byte256Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte256Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte256Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte256Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte256Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte256Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte256Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Byte256Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java 2018-04-27 15:30:58.841765016 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java 2018-04-27 15:30:58.545762291 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Byte512Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte512Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte512Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte512Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte512Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte512Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte512Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Byte512Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java 2018-04-27 15:30:59.937775100 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java 2018-04-27 15:30:59.645772413 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Byte64Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte64Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte64Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte64Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte64Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Byte64Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + byte.class, LENGTH, so, + (v, t) -> (Byte64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Byte64Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Byte64Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java 2018-04-27 15:31:01.037785220 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java 2018-04-27 15:31:00.741782498 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Double128Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double128Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double128Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double128Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double128Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double128Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double128Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Double128Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java 2018-04-27 15:31:02.157795526 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java 2018-04-27 15:31:01.857792765 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Double256Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double256Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double256Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double256Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double256Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double256Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double256Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Double256Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java 2018-04-27 15:31:03.301806051 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java 2018-04-27 15:31:02.981803108 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Double512Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double512Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double512Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double512Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double512Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double512Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double512Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Double512Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java 2018-04-27 15:31:04.397816136 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java 2018-04-27 15:31:04.101813413 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Double64Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double64Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double64Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double64Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double64Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Double64Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + double.class, LENGTH, so, + (v, t) -> (Double64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Double64Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Double64Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java 2018-04-27 15:31:05.509826367 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java 2018-04-27 15:31:05.213823644 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Float128Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float128Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float128Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float128Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float128Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float128Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float128Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Float128Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java 2018-04-27 15:31:06.653836893 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java 2018-04-27 15:31:06.333833949 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Float256Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float256Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float256Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float256Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float256Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float256Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float256Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Float256Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java 2018-04-27 15:31:07.745846941 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java 2018-04-27 15:31:07.453844255 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Float512Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float512Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float512Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float512Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float512Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float512Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float512Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Float512Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java 2018-04-27 15:31:08.849857099 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java 2018-04-27 15:31:08.549854339 -0700 @@ -1043,6 +1043,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Float64Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float64Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float64Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float64Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float64Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Float64Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + float.class, LENGTH, so, + (v, t) -> (Float64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Float64Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1091,7 +1335,7 @@ (v, t) -> (Float64Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java 2018-04-27 15:31:09.945867184 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java 2018-04-27 15:31:09.649864459 -0700 @@ -1124,6 +1124,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Int128Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int128Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int128Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int128Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int128Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int128Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int128Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1172,7 +1416,7 @@ (v, t) -> (Int128Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java 2018-04-27 15:31:11.049877341 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java 2018-04-27 15:31:10.753874617 -0700 @@ -1124,6 +1124,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Int256Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int256Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int256Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int256Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int256Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int256Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int256Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1172,7 +1416,7 @@ (v, t) -> (Int256Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java 2018-04-27 15:31:12.149887462 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java 2018-04-27 15:31:11.853884738 -0700 @@ -1124,6 +1124,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Int512Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int512Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int512Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int512Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int512Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int512Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int512Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1172,7 +1416,7 @@ (v, t) -> (Int512Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java 2018-04-27 15:31:13.245897547 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java 2018-04-27 15:31:12.949894823 -0700 @@ -1124,6 +1124,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Int64Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int64Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int64Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int64Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int64Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Int64Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + int.class, LENGTH, so, + (v, t) -> (Int64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Int64Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1172,7 +1416,7 @@ (v, t) -> (Int64Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java 2018-04-27 15:31:14.361907814 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java 2018-04-27 15:31:14.045904907 -0700 @@ -1096,6 +1096,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Long128Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long128Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long128Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long128Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long128Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long128Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long128Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1144,7 +1388,7 @@ (v, t) -> (Long128Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java 2018-04-27 15:31:15.461917936 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java 2018-04-27 15:31:15.165915212 -0700 @@ -1096,6 +1096,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Long256Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long256Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long256Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long256Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long256Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long256Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long256Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1144,7 +1388,7 @@ (v, t) -> (Long256Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java 2018-04-27 15:31:16.557928020 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java 2018-04-27 15:31:16.257925260 -0700 @@ -1096,6 +1096,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Long512Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long512Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long512Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long512Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long512Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long512Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long512Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1144,7 +1388,7 @@ (v, t) -> (Long512Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java 2018-04-27 15:31:17.657938142 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java 2018-04-27 15:31:17.361935418 -0700 @@ -1096,6 +1096,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Long64Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long64Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long64Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long64Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long64Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Long64Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + long.class, LENGTH, so, + (v, t) -> (Long64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Long64Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1144,7 +1388,7 @@ (v, t) -> (Long64Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java 2018-04-27 15:31:18.761948300 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java 2018-04-27 15:31:18.465945575 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Short128Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short128Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short128Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short128Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short128Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short128Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short128Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short128Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Short128Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java 2018-04-27 15:31:19.861958420 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java 2018-04-27 15:31:19.565955697 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Short256Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short256Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short256Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short256Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short256Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short256Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short256Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short256Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Short256Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java 2018-04-27 15:31:20.957968504 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java 2018-04-27 15:31:20.661965782 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Short512Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short512Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short512Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short512Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short512Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short512Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short512Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short512Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Short512Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java 2018-04-27 15:31:22.081978847 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java 2018-04-27 15:31:21.769975976 -0700 @@ -1023,6 +1023,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private Short64Vector castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short64Vector castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short64Vector castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short64Vector castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short64Vector castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private Short64Vector castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + short.class, LENGTH, so, + (v, t) -> (Short64Vector)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public Short64Vector cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1071,7 +1315,7 @@ (v, t) -> (Short64Vector)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java 2018-04-27 15:31:23.181988967 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java 2018-04-27 15:31:22.885986245 -0700 @@ -224,6 +224,21 @@ /* ============================================================================ */ + interface VectorCastOp { + VT apply(VF v, Class elementType); + } + + @HotSpotIntrinsicCandidate + static + + VT cast(Class fromVectorClass, Class fromElementType, int fromVLen, + Class toElementType, int toVLen, VF v, + VectorCastOp defaultImpl) { + return defaultImpl.apply(v, toElementType); + } + + /* ============================================================================ */ + @HotSpotIntrinsicCandidate static V maybeRebox(V v) { // The fence is added here to avoid memory aliasing problems in C2 between scalar & vector accesses. --- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template 2018-04-27 15:31:24.285999126 -0700 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template 2018-04-27 15:31:23.989996403 -0700 @@ -1303,6 +1303,250 @@ return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]); } + @ForceInline + @SuppressWarnings("unchecked") + private $vectortype$ castFromByte(ByteVector o) { + if (o.bitSize() == 64) { + Byte64Vector so = (Byte64Vector)o; + return VectorIntrinsics.cast( + Byte64Vector.class, byte.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Byte128Vector so = (Byte128Vector)o; + return VectorIntrinsics.cast( + Byte128Vector.class, byte.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Byte256Vector so = (Byte256Vector)o; + return VectorIntrinsics.cast( + Byte256Vector.class, byte.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Byte512Vector so = (Byte512Vector)o; + return VectorIntrinsics.cast( + Byte512Vector.class, byte.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private $vectortype$ castFromShort(ShortVector o) { + if (o.bitSize() == 64) { + Short64Vector so = (Short64Vector)o; + return VectorIntrinsics.cast( + Short64Vector.class, short.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Short128Vector so = (Short128Vector)o; + return VectorIntrinsics.cast( + Short128Vector.class, short.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Short256Vector so = (Short256Vector)o; + return VectorIntrinsics.cast( + Short256Vector.class, short.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Short512Vector so = (Short512Vector)o; + return VectorIntrinsics.cast( + Short512Vector.class, short.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private $vectortype$ castFromInt(IntVector o) { + if (o.bitSize() == 64) { + Int64Vector so = (Int64Vector)o; + return VectorIntrinsics.cast( + Int64Vector.class, int.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Int128Vector so = (Int128Vector)o; + return VectorIntrinsics.cast( + Int128Vector.class, int.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Int256Vector so = (Int256Vector)o; + return VectorIntrinsics.cast( + Int256Vector.class, int.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Int512Vector so = (Int512Vector)o; + return VectorIntrinsics.cast( + Int512Vector.class, int.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private $vectortype$ castFromLong(LongVector o) { + if (o.bitSize() == 64) { + Long64Vector so = (Long64Vector)o; + return VectorIntrinsics.cast( + Long64Vector.class, long.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Long128Vector so = (Long128Vector)o; + return VectorIntrinsics.cast( + Long128Vector.class, long.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Long256Vector so = (Long256Vector)o; + return VectorIntrinsics.cast( + Long256Vector.class, long.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Long512Vector so = (Long512Vector)o; + return VectorIntrinsics.cast( + Long512Vector.class, long.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private $vectortype$ castFromFloat(FloatVector o) { + if (o.bitSize() == 64) { + Float64Vector so = (Float64Vector)o; + return VectorIntrinsics.cast( + Float64Vector.class, float.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Float128Vector so = (Float128Vector)o; + return VectorIntrinsics.cast( + Float128Vector.class, float.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Float256Vector so = (Float256Vector)o; + return VectorIntrinsics.cast( + Float256Vector.class, float.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Float512Vector so = (Float512Vector)o; + return VectorIntrinsics.cast( + Float512Vector.class, float.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @ForceInline + @SuppressWarnings("unchecked") + private $vectortype$ castFromDouble(DoubleVector o) { + if (o.bitSize() == 64) { + Double64Vector so = (Double64Vector)o; + return VectorIntrinsics.cast( + Double64Vector.class, double.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 128) { + Double128Vector so = (Double128Vector)o; + return VectorIntrinsics.cast( + Double128Vector.class, double.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 256) { + Double256Vector so = (Double256Vector)o; + return VectorIntrinsics.cast( + Double256Vector.class, double.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else if (o.bitSize() == 512) { + Double512Vector so = (Double512Vector)o; + return VectorIntrinsics.cast( + Double512Vector.class, double.class, so.length(), + $type$.class, LENGTH, so, + (v, t) -> ($vectortype$)super.cast(v) + ); + } else { + throw new InternalError("Unimplemented size"); + } + } + + @Override + @ForceInline + @SuppressWarnings("unchecked") + public $vectortype$ cast(Vector o) { + Objects.requireNonNull(o); + if (o.elementType() == byte.class) { + ByteVector so = (ByteVector)o; + return castFromByte(so); + } else if (o.elementType() == short.class) { + ShortVector so = (ShortVector)o; + return castFromShort(so); + } else if (o.elementType() == int.class) { + IntVector so = (IntVector)o; + return castFromInt(so); + } else if (o.elementType() == long.class) { + LongVector so = (LongVector)o; + return castFromLong(so); + } else if (o.elementType() == float.class) { + FloatVector so = (FloatVector)o; + return castFromFloat(so); + } else if (o.elementType() == double.class) { + DoubleVector so = (DoubleVector)o; + return castFromDouble(so); + } else { + throw new InternalError("Unimplemented type"); + } + } + @Override @ForceInline @SuppressWarnings("unchecked") @@ -1351,7 +1595,7 @@ (v, t) -> ($vectortype$)reshape(v) ); } else { - throw new InternalError("Unimplemented size"); + throw new InternalError("Unimplemented type"); } } --- old/test/jdk/jdk/incubator/vector/VectorReshapeTests.java 2018-04-27 15:31:25.382009210 -0700 +++ new/test/jdk/jdk/incubator/vector/VectorReshapeTests.java 2018-04-27 15:31:25.090006523 -0700 @@ -92,6 +92,81 @@ return a; } + interface ToShortF { + short apply(int i); + } + + static short[] fill_short(int s , ToShortF f) { + return fill_short(new short[s], f); + } + + static short[] fill_short(short[] a, ToShortF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + interface ToIntF { + int apply(int i); + } + + static int[] fill_int(int s , ToIntF f) { + return fill_int(new int[s], f); + } + + static int[] fill_int(int[] a, ToIntF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + interface ToLongF { + long apply(int i); + } + + static long[] fill_long(int s , ToLongF f) { + return fill_long(new long[s], f); + } + + static long[] fill_long(long[] a, ToLongF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + interface ToFloatF { + float apply(int i); + } + + static float[] fill_float(int s , ToFloatF f) { + return fill_float(new float[s], f); + } + + static float[] fill_float(float[] a, ToFloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + interface ToDoubleF { + double apply(int i); + } + + static double[] fill_double(int s , ToDoubleF f) { + return fill_double(new double[s], f); + } + + static double[] fill_double(double[] a, ToDoubleF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + static final List> BYTE_GENERATORS = List.of( withToString("byte(i)", (int s) -> { return fill_byte(s, i -> (byte)i); @@ -118,13 +193,78 @@ toArray(Object[][]::new); } + static final List> SHORT_GENERATORS = List.of( + withToString("short(i)", (int s) -> { + return fill_short(s, i -> (short)i); + }) + ); + + @DataProvider + public Object[][] shortUnaryOpProvider() { + return SHORT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List> INT_GENERATORS = List.of( + withToString("int(i)", (int s) -> { + return fill_int(s, i -> (int)i); + }) + ); + + @DataProvider + public Object[][] intUnaryOpProvider() { + return INT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List> LONG_GENERATORS = List.of( + withToString("long(i)", (int s) -> { + return fill_long(s, i -> (long)i); + }) + ); + + @DataProvider + public Object[][] longUnaryOpProvider() { + return LONG_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List> FLOAT_GENERATORS = List.of( + withToString("float(i)", (int s) -> { + return fill_float(s, i -> (float)i); + }) + ); + + @DataProvider + public Object[][] floatUnaryOpProvider() { + return FLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List> DOUBLE_GENERATORS = List.of( + withToString("double(i)", (int s) -> { + return fill_double(s, i -> (double)i); + }) + ); + + @DataProvider + public Object[][] doubleUnaryOpProvider() { + return DOUBLE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + @ForceInline static void testVectorResize(Vector.Species a, Vector.Species b, byte[] input, byte[] output) { Vector av = a.fromByteArray(input, 0); Vector bv = b.resize(av); bv.intoByteArray(output, 0); - + byte[] expected = Arrays.copyOf(input, output.length); @@ -542,4 +682,1612 @@ testVectorRebracket(dspec512, dspec512, barr, bout); } } + + @ForceInline + static + void testVectorCastByteToFloat(ByteVector.ByteSpecies a, FloatVector.FloatSpecies b, byte[] input, float[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ByteVector av = a.fromArray(input, 0); + FloatVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (float)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (float)0); + } + } + + @ForceInline + static + void testVectorCastShortToFloat(ShortVector.ShortSpecies a, FloatVector.FloatSpecies b, short[] input, float[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ShortVector av = a.fromArray(input, 0); + FloatVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (float)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (float)0); + } + } + + @ForceInline + static + void testVectorCastIntToFloat(IntVector.IntSpecies a, FloatVector.FloatSpecies b, int[] input, float[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + IntVector av = a.fromArray(input, 0); + FloatVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (float)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (float)0); + } + } + + @ForceInline + static + void testVectorCastLongToFloat(LongVector.LongSpecies a, FloatVector.FloatSpecies b, long[] input, float[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + LongVector av = a.fromArray(input, 0); + FloatVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (float)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (float)0); + } + } + + @ForceInline + static + void testVectorCastFloatToFloat(FloatVector.FloatSpecies a, FloatVector.FloatSpecies b, float[] input, float[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + FloatVector av = a.fromArray(input, 0); + FloatVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (float)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (float)0); + } + } + + @ForceInline + static + void testVectorCastDoubleToFloat(DoubleVector.DoubleSpecies a, FloatVector.FloatSpecies b, double[] input, float[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + DoubleVector av = a.fromArray(input, 0); + FloatVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (float)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (float)0); + } + } + + @ForceInline + static + void testVectorCastByteToByte(ByteVector.ByteSpecies a, ByteVector.ByteSpecies b, byte[] input, byte[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ByteVector av = a.fromArray(input, 0); + ByteVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (byte)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (byte)0); + } + } + + @ForceInline + static + void testVectorCastShortToByte(ShortVector.ShortSpecies a, ByteVector.ByteSpecies b, short[] input, byte[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ShortVector av = a.fromArray(input, 0); + ByteVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (byte)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (byte)0); + } + } + + @ForceInline + static + void testVectorCastIntToByte(IntVector.IntSpecies a, ByteVector.ByteSpecies b, int[] input, byte[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + IntVector av = a.fromArray(input, 0); + ByteVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (byte)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (byte)0); + } + } + + @ForceInline + static + void testVectorCastLongToByte(LongVector.LongSpecies a, ByteVector.ByteSpecies b, long[] input, byte[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + LongVector av = a.fromArray(input, 0); + ByteVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (byte)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (byte)0); + } + } + + @ForceInline + static + void testVectorCastFloatToByte(FloatVector.FloatSpecies a, ByteVector.ByteSpecies b, float[] input, byte[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + FloatVector av = a.fromArray(input, 0); + ByteVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (byte)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (byte)0); + } + } + + @ForceInline + static + void testVectorCastDoubleToByte(DoubleVector.DoubleSpecies a, ByteVector.ByteSpecies b, double[] input, byte[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + DoubleVector av = a.fromArray(input, 0); + ByteVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (byte)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (byte)0); + } + } + + @ForceInline + static + void testVectorCastByteToShort(ByteVector.ByteSpecies a, ShortVector.ShortSpecies b, byte[] input, short[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ByteVector av = a.fromArray(input, 0); + ShortVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (short)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (short)0); + } + } + + @ForceInline + static + void testVectorCastShortToShort(ShortVector.ShortSpecies a, ShortVector.ShortSpecies b, short[] input, short[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ShortVector av = a.fromArray(input, 0); + ShortVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (short)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (short)0); + } + } + + @ForceInline + static + void testVectorCastIntToShort(IntVector.IntSpecies a, ShortVector.ShortSpecies b, int[] input, short[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + IntVector av = a.fromArray(input, 0); + ShortVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (short)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (short)0); + } + } + + @ForceInline + static + void testVectorCastLongToShort(LongVector.LongSpecies a, ShortVector.ShortSpecies b, long[] input, short[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + LongVector av = a.fromArray(input, 0); + ShortVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (short)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (short)0); + } + } + + @ForceInline + static + void testVectorCastFloatToShort(FloatVector.FloatSpecies a, ShortVector.ShortSpecies b, float[] input, short[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + FloatVector av = a.fromArray(input, 0); + ShortVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (short)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (short)0); + } + } + + @ForceInline + static + void testVectorCastDoubleToShort(DoubleVector.DoubleSpecies a, ShortVector.ShortSpecies b, double[] input, short[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + DoubleVector av = a.fromArray(input, 0); + ShortVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (short)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (short)0); + } + } + + @ForceInline + static + void testVectorCastByteToInt(ByteVector.ByteSpecies a, IntVector.IntSpecies b, byte[] input, int[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ByteVector av = a.fromArray(input, 0); + IntVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (int)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (int)0); + } + } + + @ForceInline + static + void testVectorCastShortToInt(ShortVector.ShortSpecies a, IntVector.IntSpecies b, short[] input, int[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ShortVector av = a.fromArray(input, 0); + IntVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (int)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (int)0); + } + } + + @ForceInline + static + void testVectorCastIntToInt(IntVector.IntSpecies a, IntVector.IntSpecies b, int[] input, int[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + IntVector av = a.fromArray(input, 0); + IntVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (int)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (int)0); + } + } + + @ForceInline + static + void testVectorCastLongToInt(LongVector.LongSpecies a, IntVector.IntSpecies b, long[] input, int[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + LongVector av = a.fromArray(input, 0); + IntVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (int)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (int)0); + } + } + + @ForceInline + static + void testVectorCastFloatToInt(FloatVector.FloatSpecies a, IntVector.IntSpecies b, float[] input, int[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + FloatVector av = a.fromArray(input, 0); + IntVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (int)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (int)0); + } + } + + @ForceInline + static + void testVectorCastDoubleToInt(DoubleVector.DoubleSpecies a, IntVector.IntSpecies b, double[] input, int[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + DoubleVector av = a.fromArray(input, 0); + IntVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (int)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (int)0); + } + } + + @ForceInline + static + void testVectorCastByteToLong(ByteVector.ByteSpecies a, LongVector.LongSpecies b, byte[] input, long[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ByteVector av = a.fromArray(input, 0); + LongVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (long)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (long)0); + } + } + + @ForceInline + static + void testVectorCastShortToLong(ShortVector.ShortSpecies a, LongVector.LongSpecies b, short[] input, long[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ShortVector av = a.fromArray(input, 0); + LongVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (long)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (long)0); + } + } + + @ForceInline + static + void testVectorCastIntToLong(IntVector.IntSpecies a, LongVector.LongSpecies b, int[] input, long[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + IntVector av = a.fromArray(input, 0); + LongVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (long)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (long)0); + } + } + + @ForceInline + static + void testVectorCastLongToLong(LongVector.LongSpecies a, LongVector.LongSpecies b, long[] input, long[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + LongVector av = a.fromArray(input, 0); + LongVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (long)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (long)0); + } + } + + @ForceInline + static + void testVectorCastFloatToLong(FloatVector.FloatSpecies a, LongVector.LongSpecies b, float[] input, long[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + FloatVector av = a.fromArray(input, 0); + LongVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (long)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (long)0); + } + } + + @ForceInline + static + void testVectorCastDoubleToLong(DoubleVector.DoubleSpecies a, LongVector.LongSpecies b, double[] input, long[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + DoubleVector av = a.fromArray(input, 0); + LongVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (long)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (long)0); + } + } + + @ForceInline + static + void testVectorCastByteToDouble(ByteVector.ByteSpecies a, DoubleVector.DoubleSpecies b, byte[] input, double[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ByteVector av = a.fromArray(input, 0); + DoubleVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (double)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (double)0); + } + } + + @ForceInline + static + void testVectorCastShortToDouble(ShortVector.ShortSpecies a, DoubleVector.DoubleSpecies b, short[] input, double[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + ShortVector av = a.fromArray(input, 0); + DoubleVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (double)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (double)0); + } + } + + @ForceInline + static + void testVectorCastIntToDouble(IntVector.IntSpecies a, DoubleVector.DoubleSpecies b, int[] input, double[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + IntVector av = a.fromArray(input, 0); + DoubleVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (double)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (double)0); + } + } + + @ForceInline + static + void testVectorCastLongToDouble(LongVector.LongSpecies a, DoubleVector.DoubleSpecies b, long[] input, double[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + LongVector av = a.fromArray(input, 0); + DoubleVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (double)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (double)0); + } + } + + @ForceInline + static + void testVectorCastFloatToDouble(FloatVector.FloatSpecies a, DoubleVector.DoubleSpecies b, float[] input, double[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + FloatVector av = a.fromArray(input, 0); + DoubleVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (double)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (double)0); + } + } + + @ForceInline + static + void testVectorCastDoubleToDouble(DoubleVector.DoubleSpecies a, DoubleVector.DoubleSpecies b, double[] input, double[] output) { + assert(input.length == a.length()); + assert(output.length == b.length()); + + DoubleVector av = a.fromArray(input, 0); + DoubleVector bv = b.cast(av); + bv.intoArray(output, 0); + + for (int i = 0; i < Math.min(input.length, output.length); i++) { + Assert.assertEquals(output[i], (double)input[i]); + } + for(int i = input.length; i < output.length; i++) { + Assert.assertEquals(output[i], (double)0); + } + } + + @Test(dataProvider = "byteUnaryOpProvider") + static void testCastFromByte(IntFunction fa) { + byte[] bin64 = fa.apply(bspec64.length()); + byte[] bin128 = fa.apply(bspec128.length()); + byte[] bin256 = fa.apply(bspec256.length()); + byte[] bin512 = fa.apply(bspec512.length()); + + byte[] bout64 = new byte[bspec64.length()]; + byte[] bout128 = new byte[bspec128.length()]; + byte[] bout256 = new byte[bspec256.length()]; + byte[] bout512 = new byte[bspec512.length()]; + + short[] sout64 = new short[sspec64.length()]; + short[] sout128 = new short[sspec128.length()]; + short[] sout256 = new short[sspec256.length()]; + short[] sout512 = new short[sspec512.length()]; + + int[] iout64 = new int[ispec64.length()]; + int[] iout128 = new int[ispec128.length()]; + int[] iout256 = new int[ispec256.length()]; + int[] iout512 = new int[ispec512.length()]; + + long[] lout64 = new long[lspec64.length()]; + long[] lout128 = new long[lspec128.length()]; + long[] lout256 = new long[lspec256.length()]; + long[] lout512 = new long[lspec512.length()]; + + float[] fout64 = new float[fspec64.length()]; + float[] fout128 = new float[fspec128.length()]; + float[] fout256 = new float[fspec256.length()]; + float[] fout512 = new float[fspec512.length()]; + + double[] dout64 = new double[dspec64.length()]; + double[] dout128 = new double[dspec128.length()]; + double[] dout256 = new double[dspec256.length()]; + double[] dout512 = new double[dspec512.length()]; + + for (int i = 0; i < NUM_ITER; i++) { + testVectorCastByteToByte(bspec64, bspec64, bin64, bout64); + testVectorCastByteToByte(bspec64, bspec128, bin64, bout128); + testVectorCastByteToByte(bspec64, bspec256, bin64, bout256); + testVectorCastByteToByte(bspec64, bspec512, bin64, bout512); + + testVectorCastByteToByte(bspec128, bspec64, bin128, bout64); + testVectorCastByteToByte(bspec128, bspec128, bin128, bout128); + testVectorCastByteToByte(bspec128, bspec256, bin128, bout256); + testVectorCastByteToByte(bspec128, bspec512, bin128, bout512); + + testVectorCastByteToByte(bspec256, bspec64, bin256, bout64); + testVectorCastByteToByte(bspec256, bspec128, bin256, bout128); + testVectorCastByteToByte(bspec256, bspec256, bin256, bout256); + testVectorCastByteToByte(bspec256, bspec512, bin256, bout512); + + testVectorCastByteToByte(bspec512, bspec64, bin512, bout64); + testVectorCastByteToByte(bspec512, bspec128, bin512, bout128); + testVectorCastByteToByte(bspec512, bspec256, bin512, bout256); + testVectorCastByteToByte(bspec512, bspec512, bin512, bout512); + + testVectorCastByteToShort(bspec64, sspec64, bin64, sout64); + testVectorCastByteToShort(bspec64, sspec128, bin64, sout128); + testVectorCastByteToShort(bspec64, sspec256, bin64, sout256); + testVectorCastByteToShort(bspec64, sspec512, bin64, sout512); + + testVectorCastByteToShort(bspec128, sspec64, bin128, sout64); + testVectorCastByteToShort(bspec128, sspec128, bin128, sout128); + testVectorCastByteToShort(bspec128, sspec256, bin128, sout256); + testVectorCastByteToShort(bspec128, sspec512, bin128, sout512); + + testVectorCastByteToShort(bspec256, sspec64, bin256, sout64); + testVectorCastByteToShort(bspec256, sspec128, bin256, sout128); + testVectorCastByteToShort(bspec256, sspec256, bin256, sout256); + testVectorCastByteToShort(bspec256, sspec512, bin256, sout512); + + testVectorCastByteToShort(bspec512, sspec64, bin512, sout64); + testVectorCastByteToShort(bspec512, sspec128, bin512, sout128); + testVectorCastByteToShort(bspec512, sspec256, bin512, sout256); + testVectorCastByteToShort(bspec512, sspec512, bin512, sout512); + + testVectorCastByteToInt(bspec64, ispec64, bin64, iout64); + testVectorCastByteToInt(bspec64, ispec128, bin64, iout128); + testVectorCastByteToInt(bspec64, ispec256, bin64, iout256); + testVectorCastByteToInt(bspec64, ispec512, bin64, iout512); + + testVectorCastByteToInt(bspec128, ispec64, bin128, iout64); + testVectorCastByteToInt(bspec128, ispec128, bin128, iout128); + testVectorCastByteToInt(bspec128, ispec256, bin128, iout256); + testVectorCastByteToInt(bspec128, ispec512, bin128, iout512); + + testVectorCastByteToInt(bspec256, ispec64, bin256, iout64); + testVectorCastByteToInt(bspec256, ispec128, bin256, iout128); + testVectorCastByteToInt(bspec256, ispec256, bin256, iout256); + testVectorCastByteToInt(bspec256, ispec512, bin256, iout512); + + testVectorCastByteToInt(bspec512, ispec64, bin512, iout64); + testVectorCastByteToInt(bspec512, ispec128, bin512, iout128); + testVectorCastByteToInt(bspec512, ispec256, bin512, iout256); + testVectorCastByteToInt(bspec512, ispec512, bin512, iout512); + + testVectorCastByteToLong(bspec64, lspec64, bin64, lout64); + testVectorCastByteToLong(bspec64, lspec128, bin64, lout128); + testVectorCastByteToLong(bspec64, lspec256, bin64, lout256); + testVectorCastByteToLong(bspec64, lspec512, bin64, lout512); + + testVectorCastByteToLong(bspec128, lspec64, bin128, lout64); + testVectorCastByteToLong(bspec128, lspec128, bin128, lout128); + testVectorCastByteToLong(bspec128, lspec256, bin128, lout256); + testVectorCastByteToLong(bspec128, lspec512, bin128, lout512); + + testVectorCastByteToLong(bspec256, lspec64, bin256, lout64); + testVectorCastByteToLong(bspec256, lspec128, bin256, lout128); + testVectorCastByteToLong(bspec256, lspec256, bin256, lout256); + testVectorCastByteToLong(bspec256, lspec512, bin256, lout512); + + testVectorCastByteToLong(bspec512, lspec64, bin512, lout64); + testVectorCastByteToLong(bspec512, lspec128, bin512, lout128); + testVectorCastByteToLong(bspec512, lspec256, bin512, lout256); + testVectorCastByteToLong(bspec512, lspec512, bin512, lout512); + + testVectorCastByteToFloat(bspec64, fspec64, bin64, fout64); + testVectorCastByteToFloat(bspec64, fspec128, bin64, fout128); + testVectorCastByteToFloat(bspec64, fspec256, bin64, fout256); + testVectorCastByteToFloat(bspec64, fspec512, bin64, fout512); + + testVectorCastByteToFloat(bspec128, fspec64, bin128, fout64); + testVectorCastByteToFloat(bspec128, fspec128, bin128, fout128); + testVectorCastByteToFloat(bspec128, fspec256, bin128, fout256); + testVectorCastByteToFloat(bspec128, fspec512, bin128, fout512); + + testVectorCastByteToFloat(bspec256, fspec64, bin256, fout64); + testVectorCastByteToFloat(bspec256, fspec128, bin256, fout128); + testVectorCastByteToFloat(bspec256, fspec256, bin256, fout256); + testVectorCastByteToFloat(bspec256, fspec512, bin256, fout512); + + testVectorCastByteToFloat(bspec512, fspec64, bin512, fout64); + testVectorCastByteToFloat(bspec512, fspec128, bin512, fout128); + testVectorCastByteToFloat(bspec512, fspec256, bin512, fout256); + testVectorCastByteToFloat(bspec512, fspec512, bin512, fout512); + + testVectorCastByteToDouble(bspec64, dspec64, bin64, dout64); + testVectorCastByteToDouble(bspec64, dspec128, bin64, dout128); + testVectorCastByteToDouble(bspec64, dspec256, bin64, dout256); + testVectorCastByteToDouble(bspec64, dspec512, bin64, dout512); + + testVectorCastByteToDouble(bspec128, dspec64, bin128, dout64); + testVectorCastByteToDouble(bspec128, dspec128, bin128, dout128); + testVectorCastByteToDouble(bspec128, dspec256, bin128, dout256); + testVectorCastByteToDouble(bspec128, dspec512, bin128, dout512); + + testVectorCastByteToDouble(bspec256, dspec64, bin256, dout64); + testVectorCastByteToDouble(bspec256, dspec128, bin256, dout128); + testVectorCastByteToDouble(bspec256, dspec256, bin256, dout256); + testVectorCastByteToDouble(bspec256, dspec512, bin256, dout512); + + testVectorCastByteToDouble(bspec512, dspec64, bin512, dout64); + testVectorCastByteToDouble(bspec512, dspec128, bin512, dout128); + testVectorCastByteToDouble(bspec512, dspec256, bin512, dout256); + testVectorCastByteToDouble(bspec512, dspec512, bin512, dout512); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void testCastFromShort(IntFunction fa) { + short[] sin64 = fa.apply(sspec64.length()); + short[] sin128 = fa.apply(sspec128.length()); + short[] sin256 = fa.apply(sspec256.length()); + short[] sin512 = fa.apply(sspec512.length()); + + byte[] bout64 = new byte[bspec64.length()]; + byte[] bout128 = new byte[bspec128.length()]; + byte[] bout256 = new byte[bspec256.length()]; + byte[] bout512 = new byte[bspec512.length()]; + + short[] sout64 = new short[sspec64.length()]; + short[] sout128 = new short[sspec128.length()]; + short[] sout256 = new short[sspec256.length()]; + short[] sout512 = new short[sspec512.length()]; + + int[] iout64 = new int[ispec64.length()]; + int[] iout128 = new int[ispec128.length()]; + int[] iout256 = new int[ispec256.length()]; + int[] iout512 = new int[ispec512.length()]; + + long[] lout64 = new long[lspec64.length()]; + long[] lout128 = new long[lspec128.length()]; + long[] lout256 = new long[lspec256.length()]; + long[] lout512 = new long[lspec512.length()]; + + float[] fout64 = new float[fspec64.length()]; + float[] fout128 = new float[fspec128.length()]; + float[] fout256 = new float[fspec256.length()]; + float[] fout512 = new float[fspec512.length()]; + + double[] dout64 = new double[dspec64.length()]; + double[] dout128 = new double[dspec128.length()]; + double[] dout256 = new double[dspec256.length()]; + double[] dout512 = new double[dspec512.length()]; + + for (int i = 0; i < NUM_ITER; i++) { + testVectorCastShortToByte(sspec64, bspec64, sin64, bout64); + testVectorCastShortToByte(sspec64, bspec128, sin64, bout128); + testVectorCastShortToByte(sspec64, bspec256, sin64, bout256); + testVectorCastShortToByte(sspec64, bspec512, sin64, bout512); + + testVectorCastShortToByte(sspec128, bspec64, sin128, bout64); + testVectorCastShortToByte(sspec128, bspec128, sin128, bout128); + testVectorCastShortToByte(sspec128, bspec256, sin128, bout256); + testVectorCastShortToByte(sspec128, bspec512, sin128, bout512); + + testVectorCastShortToByte(sspec256, bspec64, sin256, bout64); + testVectorCastShortToByte(sspec256, bspec128, sin256, bout128); + testVectorCastShortToByte(sspec256, bspec256, sin256, bout256); + testVectorCastShortToByte(sspec256, bspec512, sin256, bout512); + + testVectorCastShortToByte(sspec512, bspec64, sin512, bout64); + testVectorCastShortToByte(sspec512, bspec128, sin512, bout128); + testVectorCastShortToByte(sspec512, bspec256, sin512, bout256); + testVectorCastShortToByte(sspec512, bspec512, sin512, bout512); + + testVectorCastShortToShort(sspec64, sspec64, sin64, sout64); + testVectorCastShortToShort(sspec64, sspec128, sin64, sout128); + testVectorCastShortToShort(sspec64, sspec256, sin64, sout256); + testVectorCastShortToShort(sspec64, sspec512, sin64, sout512); + + testVectorCastShortToShort(sspec128, sspec64, sin128, sout64); + testVectorCastShortToShort(sspec128, sspec128, sin128, sout128); + testVectorCastShortToShort(sspec128, sspec256, sin128, sout256); + testVectorCastShortToShort(sspec128, sspec512, sin128, sout512); + + testVectorCastShortToShort(sspec256, sspec64, sin256, sout64); + testVectorCastShortToShort(sspec256, sspec128, sin256, sout128); + testVectorCastShortToShort(sspec256, sspec256, sin256, sout256); + testVectorCastShortToShort(sspec256, sspec512, sin256, sout512); + + testVectorCastShortToShort(sspec512, sspec64, sin512, sout64); + testVectorCastShortToShort(sspec512, sspec128, sin512, sout128); + testVectorCastShortToShort(sspec512, sspec256, sin512, sout256); + testVectorCastShortToShort(sspec512, sspec512, sin512, sout512); + + testVectorCastShortToInt(sspec64, ispec64, sin64, iout64); + testVectorCastShortToInt(sspec64, ispec128, sin64, iout128); + testVectorCastShortToInt(sspec64, ispec256, sin64, iout256); + testVectorCastShortToInt(sspec64, ispec512, sin64, iout512); + + testVectorCastShortToInt(sspec128, ispec64, sin128, iout64); + testVectorCastShortToInt(sspec128, ispec128, sin128, iout128); + testVectorCastShortToInt(sspec128, ispec256, sin128, iout256); + testVectorCastShortToInt(sspec128, ispec512, sin128, iout512); + + testVectorCastShortToInt(sspec256, ispec64, sin256, iout64); + testVectorCastShortToInt(sspec256, ispec128, sin256, iout128); + testVectorCastShortToInt(sspec256, ispec256, sin256, iout256); + testVectorCastShortToInt(sspec256, ispec512, sin256, iout512); + + testVectorCastShortToInt(sspec512, ispec64, sin512, iout64); + testVectorCastShortToInt(sspec512, ispec128, sin512, iout128); + testVectorCastShortToInt(sspec512, ispec256, sin512, iout256); + testVectorCastShortToInt(sspec512, ispec512, sin512, iout512); + + testVectorCastShortToLong(sspec64, lspec64, sin64, lout64); + testVectorCastShortToLong(sspec64, lspec128, sin64, lout128); + testVectorCastShortToLong(sspec64, lspec256, sin64, lout256); + testVectorCastShortToLong(sspec64, lspec512, sin64, lout512); + + testVectorCastShortToLong(sspec128, lspec64, sin128, lout64); + testVectorCastShortToLong(sspec128, lspec128, sin128, lout128); + testVectorCastShortToLong(sspec128, lspec256, sin128, lout256); + testVectorCastShortToLong(sspec128, lspec512, sin128, lout512); + + testVectorCastShortToLong(sspec256, lspec64, sin256, lout64); + testVectorCastShortToLong(sspec256, lspec128, sin256, lout128); + testVectorCastShortToLong(sspec256, lspec256, sin256, lout256); + testVectorCastShortToLong(sspec256, lspec512, sin256, lout512); + + testVectorCastShortToLong(sspec512, lspec64, sin512, lout64); + testVectorCastShortToLong(sspec512, lspec128, sin512, lout128); + testVectorCastShortToLong(sspec512, lspec256, sin512, lout256); + testVectorCastShortToLong(sspec512, lspec512, sin512, lout512); + + testVectorCastShortToFloat(sspec64, fspec64, sin64, fout64); + testVectorCastShortToFloat(sspec64, fspec128, sin64, fout128); + testVectorCastShortToFloat(sspec64, fspec256, sin64, fout256); + testVectorCastShortToFloat(sspec64, fspec512, sin64, fout512); + + testVectorCastShortToFloat(sspec128, fspec64, sin128, fout64); + testVectorCastShortToFloat(sspec128, fspec128, sin128, fout128); + testVectorCastShortToFloat(sspec128, fspec256, sin128, fout256); + testVectorCastShortToFloat(sspec128, fspec512, sin128, fout512); + + testVectorCastShortToFloat(sspec256, fspec64, sin256, fout64); + testVectorCastShortToFloat(sspec256, fspec128, sin256, fout128); + testVectorCastShortToFloat(sspec256, fspec256, sin256, fout256); + testVectorCastShortToFloat(sspec256, fspec512, sin256, fout512); + + testVectorCastShortToFloat(sspec512, fspec64, sin512, fout64); + testVectorCastShortToFloat(sspec512, fspec128, sin512, fout128); + testVectorCastShortToFloat(sspec512, fspec256, sin512, fout256); + testVectorCastShortToFloat(sspec512, fspec512, sin512, fout512); + + testVectorCastShortToDouble(sspec64, dspec64, sin64, dout64); + testVectorCastShortToDouble(sspec64, dspec128, sin64, dout128); + testVectorCastShortToDouble(sspec64, dspec256, sin64, dout256); + testVectorCastShortToDouble(sspec64, dspec512, sin64, dout512); + + testVectorCastShortToDouble(sspec128, dspec64, sin128, dout64); + testVectorCastShortToDouble(sspec128, dspec128, sin128, dout128); + testVectorCastShortToDouble(sspec128, dspec256, sin128, dout256); + testVectorCastShortToDouble(sspec128, dspec512, sin128, dout512); + + testVectorCastShortToDouble(sspec256, dspec64, sin256, dout64); + testVectorCastShortToDouble(sspec256, dspec128, sin256, dout128); + testVectorCastShortToDouble(sspec256, dspec256, sin256, dout256); + testVectorCastShortToDouble(sspec256, dspec512, sin256, dout512); + + testVectorCastShortToDouble(sspec512, dspec64, sin512, dout64); + testVectorCastShortToDouble(sspec512, dspec128, sin512, dout128); + testVectorCastShortToDouble(sspec512, dspec256, sin512, dout256); + testVectorCastShortToDouble(sspec512, dspec512, sin512, dout512); + } + } + + @Test(dataProvider = "intUnaryOpProvider") + static void testCastFromInt(IntFunction fa) { + int[] iin64 = fa.apply(ispec64.length()); + int[] iin128 = fa.apply(ispec128.length()); + int[] iin256 = fa.apply(ispec256.length()); + int[] iin512 = fa.apply(ispec512.length()); + + byte[] bout64 = new byte[bspec64.length()]; + byte[] bout128 = new byte[bspec128.length()]; + byte[] bout256 = new byte[bspec256.length()]; + byte[] bout512 = new byte[bspec512.length()]; + + short[] sout64 = new short[sspec64.length()]; + short[] sout128 = new short[sspec128.length()]; + short[] sout256 = new short[sspec256.length()]; + short[] sout512 = new short[sspec512.length()]; + + int[] iout64 = new int[ispec64.length()]; + int[] iout128 = new int[ispec128.length()]; + int[] iout256 = new int[ispec256.length()]; + int[] iout512 = new int[ispec512.length()]; + + long[] lout64 = new long[lspec64.length()]; + long[] lout128 = new long[lspec128.length()]; + long[] lout256 = new long[lspec256.length()]; + long[] lout512 = new long[lspec512.length()]; + + float[] fout64 = new float[fspec64.length()]; + float[] fout128 = new float[fspec128.length()]; + float[] fout256 = new float[fspec256.length()]; + float[] fout512 = new float[fspec512.length()]; + + double[] dout64 = new double[dspec64.length()]; + double[] dout128 = new double[dspec128.length()]; + double[] dout256 = new double[dspec256.length()]; + double[] dout512 = new double[dspec512.length()]; + + for (int i = 0; i < NUM_ITER; i++) { + testVectorCastIntToByte(ispec64, bspec64, iin64, bout64); + testVectorCastIntToByte(ispec64, bspec128, iin64, bout128); + testVectorCastIntToByte(ispec64, bspec256, iin64, bout256); + testVectorCastIntToByte(ispec64, bspec512, iin64, bout512); + + testVectorCastIntToByte(ispec128, bspec64, iin128, bout64); + testVectorCastIntToByte(ispec128, bspec128, iin128, bout128); + testVectorCastIntToByte(ispec128, bspec256, iin128, bout256); + testVectorCastIntToByte(ispec128, bspec512, iin128, bout512); + + testVectorCastIntToByte(ispec256, bspec64, iin256, bout64); + testVectorCastIntToByte(ispec256, bspec128, iin256, bout128); + testVectorCastIntToByte(ispec256, bspec256, iin256, bout256); + testVectorCastIntToByte(ispec256, bspec512, iin256, bout512); + + testVectorCastIntToByte(ispec512, bspec64, iin512, bout64); + testVectorCastIntToByte(ispec512, bspec128, iin512, bout128); + testVectorCastIntToByte(ispec512, bspec256, iin512, bout256); + testVectorCastIntToByte(ispec512, bspec512, iin512, bout512); + + testVectorCastIntToShort(ispec64, sspec64, iin64, sout64); + testVectorCastIntToShort(ispec64, sspec128, iin64, sout128); + testVectorCastIntToShort(ispec64, sspec256, iin64, sout256); + testVectorCastIntToShort(ispec64, sspec512, iin64, sout512); + + testVectorCastIntToShort(ispec128, sspec64, iin128, sout64); + testVectorCastIntToShort(ispec128, sspec128, iin128, sout128); + testVectorCastIntToShort(ispec128, sspec256, iin128, sout256); + testVectorCastIntToShort(ispec128, sspec512, iin128, sout512); + + testVectorCastIntToShort(ispec256, sspec64, iin256, sout64); + testVectorCastIntToShort(ispec256, sspec128, iin256, sout128); + testVectorCastIntToShort(ispec256, sspec256, iin256, sout256); + testVectorCastIntToShort(ispec256, sspec512, iin256, sout512); + + testVectorCastIntToShort(ispec512, sspec64, iin512, sout64); + testVectorCastIntToShort(ispec512, sspec128, iin512, sout128); + testVectorCastIntToShort(ispec512, sspec256, iin512, sout256); + testVectorCastIntToShort(ispec512, sspec512, iin512, sout512); + + testVectorCastIntToInt(ispec64, ispec64, iin64, iout64); + testVectorCastIntToInt(ispec64, ispec128, iin64, iout128); + testVectorCastIntToInt(ispec64, ispec256, iin64, iout256); + testVectorCastIntToInt(ispec64, ispec512, iin64, iout512); + + testVectorCastIntToInt(ispec128, ispec64, iin128, iout64); + testVectorCastIntToInt(ispec128, ispec128, iin128, iout128); + testVectorCastIntToInt(ispec128, ispec256, iin128, iout256); + testVectorCastIntToInt(ispec128, ispec512, iin128, iout512); + + testVectorCastIntToInt(ispec256, ispec64, iin256, iout64); + testVectorCastIntToInt(ispec256, ispec128, iin256, iout128); + testVectorCastIntToInt(ispec256, ispec256, iin256, iout256); + testVectorCastIntToInt(ispec256, ispec512, iin256, iout512); + + testVectorCastIntToInt(ispec512, ispec64, iin512, iout64); + testVectorCastIntToInt(ispec512, ispec128, iin512, iout128); + testVectorCastIntToInt(ispec512, ispec256, iin512, iout256); + testVectorCastIntToInt(ispec512, ispec512, iin512, iout512); + + testVectorCastIntToLong(ispec64, lspec64, iin64, lout64); + testVectorCastIntToLong(ispec64, lspec128, iin64, lout128); + testVectorCastIntToLong(ispec64, lspec256, iin64, lout256); + testVectorCastIntToLong(ispec64, lspec512, iin64, lout512); + + testVectorCastIntToLong(ispec128, lspec64, iin128, lout64); + testVectorCastIntToLong(ispec128, lspec128, iin128, lout128); + testVectorCastIntToLong(ispec128, lspec256, iin128, lout256); + testVectorCastIntToLong(ispec128, lspec512, iin128, lout512); + + testVectorCastIntToLong(ispec256, lspec64, iin256, lout64); + testVectorCastIntToLong(ispec256, lspec128, iin256, lout128); + testVectorCastIntToLong(ispec256, lspec256, iin256, lout256); + testVectorCastIntToLong(ispec256, lspec512, iin256, lout512); + + testVectorCastIntToLong(ispec512, lspec64, iin512, lout64); + testVectorCastIntToLong(ispec512, lspec128, iin512, lout128); + testVectorCastIntToLong(ispec512, lspec256, iin512, lout256); + testVectorCastIntToLong(ispec512, lspec512, iin512, lout512); + + testVectorCastIntToFloat(ispec64, fspec64, iin64, fout64); + testVectorCastIntToFloat(ispec64, fspec128, iin64, fout128); + testVectorCastIntToFloat(ispec64, fspec256, iin64, fout256); + testVectorCastIntToFloat(ispec64, fspec512, iin64, fout512); + + testVectorCastIntToFloat(ispec128, fspec64, iin128, fout64); + testVectorCastIntToFloat(ispec128, fspec128, iin128, fout128); + testVectorCastIntToFloat(ispec128, fspec256, iin128, fout256); + testVectorCastIntToFloat(ispec128, fspec512, iin128, fout512); + + testVectorCastIntToFloat(ispec256, fspec64, iin256, fout64); + testVectorCastIntToFloat(ispec256, fspec128, iin256, fout128); + testVectorCastIntToFloat(ispec256, fspec256, iin256, fout256); + testVectorCastIntToFloat(ispec256, fspec512, iin256, fout512); + + testVectorCastIntToFloat(ispec512, fspec64, iin512, fout64); + testVectorCastIntToFloat(ispec512, fspec128, iin512, fout128); + testVectorCastIntToFloat(ispec512, fspec256, iin512, fout256); + testVectorCastIntToFloat(ispec512, fspec512, iin512, fout512); + + testVectorCastIntToDouble(ispec64, dspec64, iin64, dout64); + testVectorCastIntToDouble(ispec64, dspec128, iin64, dout128); + testVectorCastIntToDouble(ispec64, dspec256, iin64, dout256); + testVectorCastIntToDouble(ispec64, dspec512, iin64, dout512); + + testVectorCastIntToDouble(ispec128, dspec64, iin128, dout64); + testVectorCastIntToDouble(ispec128, dspec128, iin128, dout128); + testVectorCastIntToDouble(ispec128, dspec256, iin128, dout256); + testVectorCastIntToDouble(ispec128, dspec512, iin128, dout512); + + testVectorCastIntToDouble(ispec256, dspec64, iin256, dout64); + testVectorCastIntToDouble(ispec256, dspec128, iin256, dout128); + testVectorCastIntToDouble(ispec256, dspec256, iin256, dout256); + testVectorCastIntToDouble(ispec256, dspec512, iin256, dout512); + + testVectorCastIntToDouble(ispec512, dspec64, iin512, dout64); + testVectorCastIntToDouble(ispec512, dspec128, iin512, dout128); + testVectorCastIntToDouble(ispec512, dspec256, iin512, dout256); + testVectorCastIntToDouble(ispec512, dspec512, iin512, dout512); + } + } + + @Test(dataProvider = "longUnaryOpProvider") + static void testCastFromLong(IntFunction fa) { + long[] lin64 = fa.apply(lspec64.length()); + long[] lin128 = fa.apply(lspec128.length()); + long[] lin256 = fa.apply(lspec256.length()); + long[] lin512 = fa.apply(lspec512.length()); + + byte[] bout64 = new byte[bspec64.length()]; + byte[] bout128 = new byte[bspec128.length()]; + byte[] bout256 = new byte[bspec256.length()]; + byte[] bout512 = new byte[bspec512.length()]; + + short[] sout64 = new short[sspec64.length()]; + short[] sout128 = new short[sspec128.length()]; + short[] sout256 = new short[sspec256.length()]; + short[] sout512 = new short[sspec512.length()]; + + int[] iout64 = new int[ispec64.length()]; + int[] iout128 = new int[ispec128.length()]; + int[] iout256 = new int[ispec256.length()]; + int[] iout512 = new int[ispec512.length()]; + + long[] lout64 = new long[lspec64.length()]; + long[] lout128 = new long[lspec128.length()]; + long[] lout256 = new long[lspec256.length()]; + long[] lout512 = new long[lspec512.length()]; + + float[] fout64 = new float[fspec64.length()]; + float[] fout128 = new float[fspec128.length()]; + float[] fout256 = new float[fspec256.length()]; + float[] fout512 = new float[fspec512.length()]; + + double[] dout64 = new double[dspec64.length()]; + double[] dout128 = new double[dspec128.length()]; + double[] dout256 = new double[dspec256.length()]; + double[] dout512 = new double[dspec512.length()]; + + for (int i = 0; i < NUM_ITER; i++) { + testVectorCastLongToByte(lspec64, bspec64, lin64, bout64); + testVectorCastLongToByte(lspec64, bspec128, lin64, bout128); + testVectorCastLongToByte(lspec64, bspec256, lin64, bout256); + testVectorCastLongToByte(lspec64, bspec512, lin64, bout512); + + testVectorCastLongToByte(lspec128, bspec64, lin128, bout64); + testVectorCastLongToByte(lspec128, bspec128, lin128, bout128); + testVectorCastLongToByte(lspec128, bspec256, lin128, bout256); + testVectorCastLongToByte(lspec128, bspec512, lin128, bout512); + + testVectorCastLongToByte(lspec256, bspec64, lin256, bout64); + testVectorCastLongToByte(lspec256, bspec128, lin256, bout128); + testVectorCastLongToByte(lspec256, bspec256, lin256, bout256); + testVectorCastLongToByte(lspec256, bspec512, lin256, bout512); + + testVectorCastLongToByte(lspec512, bspec64, lin512, bout64); + testVectorCastLongToByte(lspec512, bspec128, lin512, bout128); + testVectorCastLongToByte(lspec512, bspec256, lin512, bout256); + testVectorCastLongToByte(lspec512, bspec512, lin512, bout512); + + testVectorCastLongToShort(lspec64, sspec64, lin64, sout64); + testVectorCastLongToShort(lspec64, sspec128, lin64, sout128); + testVectorCastLongToShort(lspec64, sspec256, lin64, sout256); + testVectorCastLongToShort(lspec64, sspec512, lin64, sout512); + + testVectorCastLongToShort(lspec128, sspec64, lin128, sout64); + testVectorCastLongToShort(lspec128, sspec128, lin128, sout128); + testVectorCastLongToShort(lspec128, sspec256, lin128, sout256); + testVectorCastLongToShort(lspec128, sspec512, lin128, sout512); + + testVectorCastLongToShort(lspec256, sspec64, lin256, sout64); + testVectorCastLongToShort(lspec256, sspec128, lin256, sout128); + testVectorCastLongToShort(lspec256, sspec256, lin256, sout256); + testVectorCastLongToShort(lspec256, sspec512, lin256, sout512); + + testVectorCastLongToShort(lspec512, sspec64, lin512, sout64); + testVectorCastLongToShort(lspec512, sspec128, lin512, sout128); + testVectorCastLongToShort(lspec512, sspec256, lin512, sout256); + testVectorCastLongToShort(lspec512, sspec512, lin512, sout512); + + testVectorCastLongToInt(lspec64, ispec64, lin64, iout64); + testVectorCastLongToInt(lspec64, ispec128, lin64, iout128); + testVectorCastLongToInt(lspec64, ispec256, lin64, iout256); + testVectorCastLongToInt(lspec64, ispec512, lin64, iout512); + + testVectorCastLongToInt(lspec128, ispec64, lin128, iout64); + testVectorCastLongToInt(lspec128, ispec128, lin128, iout128); + testVectorCastLongToInt(lspec128, ispec256, lin128, iout256); + testVectorCastLongToInt(lspec128, ispec512, lin128, iout512); + + testVectorCastLongToInt(lspec256, ispec64, lin256, iout64); + testVectorCastLongToInt(lspec256, ispec128, lin256, iout128); + testVectorCastLongToInt(lspec256, ispec256, lin256, iout256); + testVectorCastLongToInt(lspec256, ispec512, lin256, iout512); + + testVectorCastLongToInt(lspec512, ispec64, lin512, iout64); + testVectorCastLongToInt(lspec512, ispec128, lin512, iout128); + testVectorCastLongToInt(lspec512, ispec256, lin512, iout256); + testVectorCastLongToInt(lspec512, ispec512, lin512, iout512); + + testVectorCastLongToLong(lspec64, lspec64, lin64, lout64); + testVectorCastLongToLong(lspec64, lspec128, lin64, lout128); + testVectorCastLongToLong(lspec64, lspec256, lin64, lout256); + testVectorCastLongToLong(lspec64, lspec512, lin64, lout512); + + testVectorCastLongToLong(lspec128, lspec64, lin128, lout64); + testVectorCastLongToLong(lspec128, lspec128, lin128, lout128); + testVectorCastLongToLong(lspec128, lspec256, lin128, lout256); + testVectorCastLongToLong(lspec128, lspec512, lin128, lout512); + + testVectorCastLongToLong(lspec256, lspec64, lin256, lout64); + testVectorCastLongToLong(lspec256, lspec128, lin256, lout128); + testVectorCastLongToLong(lspec256, lspec256, lin256, lout256); + testVectorCastLongToLong(lspec256, lspec512, lin256, lout512); + + testVectorCastLongToLong(lspec512, lspec64, lin512, lout64); + testVectorCastLongToLong(lspec512, lspec128, lin512, lout128); + testVectorCastLongToLong(lspec512, lspec256, lin512, lout256); + testVectorCastLongToLong(lspec512, lspec512, lin512, lout512); + + testVectorCastLongToFloat(lspec64, fspec64, lin64, fout64); + testVectorCastLongToFloat(lspec64, fspec128, lin64, fout128); + testVectorCastLongToFloat(lspec64, fspec256, lin64, fout256); + testVectorCastLongToFloat(lspec64, fspec512, lin64, fout512); + + testVectorCastLongToFloat(lspec128, fspec64, lin128, fout64); + testVectorCastLongToFloat(lspec128, fspec128, lin128, fout128); + testVectorCastLongToFloat(lspec128, fspec256, lin128, fout256); + testVectorCastLongToFloat(lspec128, fspec512, lin128, fout512); + + testVectorCastLongToFloat(lspec256, fspec64, lin256, fout64); + testVectorCastLongToFloat(lspec256, fspec128, lin256, fout128); + testVectorCastLongToFloat(lspec256, fspec256, lin256, fout256); + testVectorCastLongToFloat(lspec256, fspec512, lin256, fout512); + + testVectorCastLongToFloat(lspec512, fspec64, lin512, fout64); + testVectorCastLongToFloat(lspec512, fspec128, lin512, fout128); + testVectorCastLongToFloat(lspec512, fspec256, lin512, fout256); + testVectorCastLongToFloat(lspec512, fspec512, lin512, fout512); + + testVectorCastLongToDouble(lspec64, dspec64, lin64, dout64); + testVectorCastLongToDouble(lspec64, dspec128, lin64, dout128); + testVectorCastLongToDouble(lspec64, dspec256, lin64, dout256); + testVectorCastLongToDouble(lspec64, dspec512, lin64, dout512); + + testVectorCastLongToDouble(lspec128, dspec64, lin128, dout64); + testVectorCastLongToDouble(lspec128, dspec128, lin128, dout128); + testVectorCastLongToDouble(lspec128, dspec256, lin128, dout256); + testVectorCastLongToDouble(lspec128, dspec512, lin128, dout512); + + testVectorCastLongToDouble(lspec256, dspec64, lin256, dout64); + testVectorCastLongToDouble(lspec256, dspec128, lin256, dout128); + testVectorCastLongToDouble(lspec256, dspec256, lin256, dout256); + testVectorCastLongToDouble(lspec256, dspec512, lin256, dout512); + + testVectorCastLongToDouble(lspec512, dspec64, lin512, dout64); + testVectorCastLongToDouble(lspec512, dspec128, lin512, dout128); + testVectorCastLongToDouble(lspec512, dspec256, lin512, dout256); + testVectorCastLongToDouble(lspec512, dspec512, lin512, dout512); + } + } + + @Test(dataProvider = "floatUnaryOpProvider") + static void testCastFromFloat(IntFunction fa) { + float[] fin64 = fa.apply(fspec64.length()); + float[] fin128 = fa.apply(fspec128.length()); + float[] fin256 = fa.apply(fspec256.length()); + float[] fin512 = fa.apply(fspec512.length()); + + byte[] bout64 = new byte[bspec64.length()]; + byte[] bout128 = new byte[bspec128.length()]; + byte[] bout256 = new byte[bspec256.length()]; + byte[] bout512 = new byte[bspec512.length()]; + + short[] sout64 = new short[sspec64.length()]; + short[] sout128 = new short[sspec128.length()]; + short[] sout256 = new short[sspec256.length()]; + short[] sout512 = new short[sspec512.length()]; + + int[] iout64 = new int[ispec64.length()]; + int[] iout128 = new int[ispec128.length()]; + int[] iout256 = new int[ispec256.length()]; + int[] iout512 = new int[ispec512.length()]; + + long[] lout64 = new long[lspec64.length()]; + long[] lout128 = new long[lspec128.length()]; + long[] lout256 = new long[lspec256.length()]; + long[] lout512 = new long[lspec512.length()]; + + float[] fout64 = new float[fspec64.length()]; + float[] fout128 = new float[fspec128.length()]; + float[] fout256 = new float[fspec256.length()]; + float[] fout512 = new float[fspec512.length()]; + + double[] dout64 = new double[dspec64.length()]; + double[] dout128 = new double[dspec128.length()]; + double[] dout256 = new double[dspec256.length()]; + double[] dout512 = new double[dspec512.length()]; + + for (int i = 0; i < NUM_ITER; i++) { + testVectorCastFloatToByte(fspec64, bspec64, fin64, bout64); + testVectorCastFloatToByte(fspec64, bspec128, fin64, bout128); + testVectorCastFloatToByte(fspec64, bspec256, fin64, bout256); + testVectorCastFloatToByte(fspec64, bspec512, fin64, bout512); + + testVectorCastFloatToByte(fspec128, bspec64, fin128, bout64); + testVectorCastFloatToByte(fspec128, bspec128, fin128, bout128); + testVectorCastFloatToByte(fspec128, bspec256, fin128, bout256); + testVectorCastFloatToByte(fspec128, bspec512, fin128, bout512); + + testVectorCastFloatToByte(fspec256, bspec64, fin256, bout64); + testVectorCastFloatToByte(fspec256, bspec128, fin256, bout128); + testVectorCastFloatToByte(fspec256, bspec256, fin256, bout256); + testVectorCastFloatToByte(fspec256, bspec512, fin256, bout512); + + testVectorCastFloatToByte(fspec512, bspec64, fin512, bout64); + testVectorCastFloatToByte(fspec512, bspec128, fin512, bout128); + testVectorCastFloatToByte(fspec512, bspec256, fin512, bout256); + testVectorCastFloatToByte(fspec512, bspec512, fin512, bout512); + + testVectorCastFloatToShort(fspec64, sspec64, fin64, sout64); + testVectorCastFloatToShort(fspec64, sspec128, fin64, sout128); + testVectorCastFloatToShort(fspec64, sspec256, fin64, sout256); + testVectorCastFloatToShort(fspec64, sspec512, fin64, sout512); + + testVectorCastFloatToShort(fspec128, sspec64, fin128, sout64); + testVectorCastFloatToShort(fspec128, sspec128, fin128, sout128); + testVectorCastFloatToShort(fspec128, sspec256, fin128, sout256); + testVectorCastFloatToShort(fspec128, sspec512, fin128, sout512); + + testVectorCastFloatToShort(fspec256, sspec64, fin256, sout64); + testVectorCastFloatToShort(fspec256, sspec128, fin256, sout128); + testVectorCastFloatToShort(fspec256, sspec256, fin256, sout256); + testVectorCastFloatToShort(fspec256, sspec512, fin256, sout512); + + testVectorCastFloatToShort(fspec512, sspec64, fin512, sout64); + testVectorCastFloatToShort(fspec512, sspec128, fin512, sout128); + testVectorCastFloatToShort(fspec512, sspec256, fin512, sout256); + testVectorCastFloatToShort(fspec512, sspec512, fin512, sout512); + + testVectorCastFloatToInt(fspec64, ispec64, fin64, iout64); + testVectorCastFloatToInt(fspec64, ispec128, fin64, iout128); + testVectorCastFloatToInt(fspec64, ispec256, fin64, iout256); + testVectorCastFloatToInt(fspec64, ispec512, fin64, iout512); + + testVectorCastFloatToInt(fspec128, ispec64, fin128, iout64); + testVectorCastFloatToInt(fspec128, ispec128, fin128, iout128); + testVectorCastFloatToInt(fspec128, ispec256, fin128, iout256); + testVectorCastFloatToInt(fspec128, ispec512, fin128, iout512); + + testVectorCastFloatToInt(fspec256, ispec64, fin256, iout64); + testVectorCastFloatToInt(fspec256, ispec128, fin256, iout128); + testVectorCastFloatToInt(fspec256, ispec256, fin256, iout256); + testVectorCastFloatToInt(fspec256, ispec512, fin256, iout512); + + testVectorCastFloatToInt(fspec512, ispec64, fin512, iout64); + testVectorCastFloatToInt(fspec512, ispec128, fin512, iout128); + testVectorCastFloatToInt(fspec512, ispec256, fin512, iout256); + testVectorCastFloatToInt(fspec512, ispec512, fin512, iout512); + + testVectorCastFloatToLong(fspec64, lspec64, fin64, lout64); + testVectorCastFloatToLong(fspec64, lspec128, fin64, lout128); + testVectorCastFloatToLong(fspec64, lspec256, fin64, lout256); + testVectorCastFloatToLong(fspec64, lspec512, fin64, lout512); + + testVectorCastFloatToLong(fspec128, lspec64, fin128, lout64); + testVectorCastFloatToLong(fspec128, lspec128, fin128, lout128); + testVectorCastFloatToLong(fspec128, lspec256, fin128, lout256); + testVectorCastFloatToLong(fspec128, lspec512, fin128, lout512); + + testVectorCastFloatToLong(fspec256, lspec64, fin256, lout64); + testVectorCastFloatToLong(fspec256, lspec128, fin256, lout128); + testVectorCastFloatToLong(fspec256, lspec256, fin256, lout256); + testVectorCastFloatToLong(fspec256, lspec512, fin256, lout512); + + testVectorCastFloatToLong(fspec512, lspec64, fin512, lout64); + testVectorCastFloatToLong(fspec512, lspec128, fin512, lout128); + testVectorCastFloatToLong(fspec512, lspec256, fin512, lout256); + testVectorCastFloatToLong(fspec512, lspec512, fin512, lout512); + + testVectorCastFloatToFloat(fspec64, fspec64, fin64, fout64); + testVectorCastFloatToFloat(fspec64, fspec128, fin64, fout128); + testVectorCastFloatToFloat(fspec64, fspec256, fin64, fout256); + testVectorCastFloatToFloat(fspec64, fspec512, fin64, fout512); + + testVectorCastFloatToFloat(fspec128, fspec64, fin128, fout64); + testVectorCastFloatToFloat(fspec128, fspec128, fin128, fout128); + testVectorCastFloatToFloat(fspec128, fspec256, fin128, fout256); + testVectorCastFloatToFloat(fspec128, fspec512, fin128, fout512); + + testVectorCastFloatToFloat(fspec256, fspec64, fin256, fout64); + testVectorCastFloatToFloat(fspec256, fspec128, fin256, fout128); + testVectorCastFloatToFloat(fspec256, fspec256, fin256, fout256); + testVectorCastFloatToFloat(fspec256, fspec512, fin256, fout512); + + testVectorCastFloatToFloat(fspec512, fspec64, fin512, fout64); + testVectorCastFloatToFloat(fspec512, fspec128, fin512, fout128); + testVectorCastFloatToFloat(fspec512, fspec256, fin512, fout256); + testVectorCastFloatToFloat(fspec512, fspec512, fin512, fout512); + + testVectorCastFloatToDouble(fspec64, dspec64, fin64, dout64); + testVectorCastFloatToDouble(fspec64, dspec128, fin64, dout128); + testVectorCastFloatToDouble(fspec64, dspec256, fin64, dout256); + testVectorCastFloatToDouble(fspec64, dspec512, fin64, dout512); + + testVectorCastFloatToDouble(fspec128, dspec64, fin128, dout64); + testVectorCastFloatToDouble(fspec128, dspec128, fin128, dout128); + testVectorCastFloatToDouble(fspec128, dspec256, fin128, dout256); + testVectorCastFloatToDouble(fspec128, dspec512, fin128, dout512); + + testVectorCastFloatToDouble(fspec256, dspec64, fin256, dout64); + testVectorCastFloatToDouble(fspec256, dspec128, fin256, dout128); + testVectorCastFloatToDouble(fspec256, dspec256, fin256, dout256); + testVectorCastFloatToDouble(fspec256, dspec512, fin256, dout512); + + testVectorCastFloatToDouble(fspec512, dspec64, fin512, dout64); + testVectorCastFloatToDouble(fspec512, dspec128, fin512, dout128); + testVectorCastFloatToDouble(fspec512, dspec256, fin512, dout256); + testVectorCastFloatToDouble(fspec512, dspec512, fin512, dout512); + } + } + + @Test(dataProvider = "doubleUnaryOpProvider") + static void testCastFromDouble(IntFunction fa) { + double[] din64 = fa.apply(dspec64.length()); + double[] din128 = fa.apply(dspec128.length()); + double[] din256 = fa.apply(dspec256.length()); + double[] din512 = fa.apply(dspec512.length()); + + byte[] bout64 = new byte[bspec64.length()]; + byte[] bout128 = new byte[bspec128.length()]; + byte[] bout256 = new byte[bspec256.length()]; + byte[] bout512 = new byte[bspec512.length()]; + + short[] sout64 = new short[sspec64.length()]; + short[] sout128 = new short[sspec128.length()]; + short[] sout256 = new short[sspec256.length()]; + short[] sout512 = new short[sspec512.length()]; + + int[] iout64 = new int[ispec64.length()]; + int[] iout128 = new int[ispec128.length()]; + int[] iout256 = new int[ispec256.length()]; + int[] iout512 = new int[ispec512.length()]; + + long[] lout64 = new long[lspec64.length()]; + long[] lout128 = new long[lspec128.length()]; + long[] lout256 = new long[lspec256.length()]; + long[] lout512 = new long[lspec512.length()]; + + float[] fout64 = new float[fspec64.length()]; + float[] fout128 = new float[fspec128.length()]; + float[] fout256 = new float[fspec256.length()]; + float[] fout512 = new float[fspec512.length()]; + + double[] dout64 = new double[dspec64.length()]; + double[] dout128 = new double[dspec128.length()]; + double[] dout256 = new double[dspec256.length()]; + double[] dout512 = new double[dspec512.length()]; + + for (int i = 0; i < NUM_ITER; i++) { + testVectorCastDoubleToByte(dspec64, bspec64, din64, bout64); + testVectorCastDoubleToByte(dspec64, bspec128, din64, bout128); + testVectorCastDoubleToByte(dspec64, bspec256, din64, bout256); + testVectorCastDoubleToByte(dspec64, bspec512, din64, bout512); + + testVectorCastDoubleToByte(dspec128, bspec64, din128, bout64); + testVectorCastDoubleToByte(dspec128, bspec128, din128, bout128); + testVectorCastDoubleToByte(dspec128, bspec256, din128, bout256); + testVectorCastDoubleToByte(dspec128, bspec512, din128, bout512); + + testVectorCastDoubleToByte(dspec256, bspec64, din256, bout64); + testVectorCastDoubleToByte(dspec256, bspec128, din256, bout128); + testVectorCastDoubleToByte(dspec256, bspec256, din256, bout256); + testVectorCastDoubleToByte(dspec256, bspec512, din256, bout512); + + testVectorCastDoubleToByte(dspec512, bspec64, din512, bout64); + testVectorCastDoubleToByte(dspec512, bspec128, din512, bout128); + testVectorCastDoubleToByte(dspec512, bspec256, din512, bout256); + testVectorCastDoubleToByte(dspec512, bspec512, din512, bout512); + + testVectorCastDoubleToShort(dspec64, sspec64, din64, sout64); + testVectorCastDoubleToShort(dspec64, sspec128, din64, sout128); + testVectorCastDoubleToShort(dspec64, sspec256, din64, sout256); + testVectorCastDoubleToShort(dspec64, sspec512, din64, sout512); + + testVectorCastDoubleToShort(dspec128, sspec64, din128, sout64); + testVectorCastDoubleToShort(dspec128, sspec128, din128, sout128); + testVectorCastDoubleToShort(dspec128, sspec256, din128, sout256); + testVectorCastDoubleToShort(dspec128, sspec512, din128, sout512); + + testVectorCastDoubleToShort(dspec256, sspec64, din256, sout64); + testVectorCastDoubleToShort(dspec256, sspec128, din256, sout128); + testVectorCastDoubleToShort(dspec256, sspec256, din256, sout256); + testVectorCastDoubleToShort(dspec256, sspec512, din256, sout512); + + testVectorCastDoubleToShort(dspec512, sspec64, din512, sout64); + testVectorCastDoubleToShort(dspec512, sspec128, din512, sout128); + testVectorCastDoubleToShort(dspec512, sspec256, din512, sout256); + testVectorCastDoubleToShort(dspec512, sspec512, din512, sout512); + + testVectorCastDoubleToInt(dspec64, ispec64, din64, iout64); + testVectorCastDoubleToInt(dspec64, ispec128, din64, iout128); + testVectorCastDoubleToInt(dspec64, ispec256, din64, iout256); + testVectorCastDoubleToInt(dspec64, ispec512, din64, iout512); + + testVectorCastDoubleToInt(dspec128, ispec64, din128, iout64); + testVectorCastDoubleToInt(dspec128, ispec128, din128, iout128); + testVectorCastDoubleToInt(dspec128, ispec256, din128, iout256); + testVectorCastDoubleToInt(dspec128, ispec512, din128, iout512); + + testVectorCastDoubleToInt(dspec256, ispec64, din256, iout64); + testVectorCastDoubleToInt(dspec256, ispec128, din256, iout128); + testVectorCastDoubleToInt(dspec256, ispec256, din256, iout256); + testVectorCastDoubleToInt(dspec256, ispec512, din256, iout512); + + testVectorCastDoubleToInt(dspec512, ispec64, din512, iout64); + testVectorCastDoubleToInt(dspec512, ispec128, din512, iout128); + testVectorCastDoubleToInt(dspec512, ispec256, din512, iout256); + testVectorCastDoubleToInt(dspec512, ispec512, din512, iout512); + + testVectorCastDoubleToLong(dspec64, lspec64, din64, lout64); + testVectorCastDoubleToLong(dspec64, lspec128, din64, lout128); + testVectorCastDoubleToLong(dspec64, lspec256, din64, lout256); + testVectorCastDoubleToLong(dspec64, lspec512, din64, lout512); + + testVectorCastDoubleToLong(dspec128, lspec64, din128, lout64); + testVectorCastDoubleToLong(dspec128, lspec128, din128, lout128); + testVectorCastDoubleToLong(dspec128, lspec256, din128, lout256); + testVectorCastDoubleToLong(dspec128, lspec512, din128, lout512); + + testVectorCastDoubleToLong(dspec256, lspec64, din256, lout64); + testVectorCastDoubleToLong(dspec256, lspec128, din256, lout128); + testVectorCastDoubleToLong(dspec256, lspec256, din256, lout256); + testVectorCastDoubleToLong(dspec256, lspec512, din256, lout512); + + testVectorCastDoubleToLong(dspec512, lspec64, din512, lout64); + testVectorCastDoubleToLong(dspec512, lspec128, din512, lout128); + testVectorCastDoubleToLong(dspec512, lspec256, din512, lout256); + testVectorCastDoubleToLong(dspec512, lspec512, din512, lout512); + + testVectorCastDoubleToFloat(dspec64, fspec64, din64, fout64); + testVectorCastDoubleToFloat(dspec64, fspec128, din64, fout128); + testVectorCastDoubleToFloat(dspec64, fspec256, din64, fout256); + testVectorCastDoubleToFloat(dspec64, fspec512, din64, fout512); + + testVectorCastDoubleToFloat(dspec128, fspec64, din128, fout64); + testVectorCastDoubleToFloat(dspec128, fspec128, din128, fout128); + testVectorCastDoubleToFloat(dspec128, fspec256, din128, fout256); + testVectorCastDoubleToFloat(dspec128, fspec512, din128, fout512); + + testVectorCastDoubleToFloat(dspec256, fspec64, din256, fout64); + testVectorCastDoubleToFloat(dspec256, fspec128, din256, fout128); + testVectorCastDoubleToFloat(dspec256, fspec256, din256, fout256); + testVectorCastDoubleToFloat(dspec256, fspec512, din256, fout512); + + testVectorCastDoubleToFloat(dspec512, fspec64, din512, fout64); + testVectorCastDoubleToFloat(dspec512, fspec128, din512, fout128); + testVectorCastDoubleToFloat(dspec512, fspec256, din512, fout256); + testVectorCastDoubleToFloat(dspec512, fspec512, din512, fout512); + + testVectorCastDoubleToDouble(dspec64, dspec64, din64, dout64); + testVectorCastDoubleToDouble(dspec64, dspec128, din64, dout128); + testVectorCastDoubleToDouble(dspec64, dspec256, din64, dout256); + testVectorCastDoubleToDouble(dspec64, dspec512, din64, dout512); + + testVectorCastDoubleToDouble(dspec128, dspec64, din128, dout64); + testVectorCastDoubleToDouble(dspec128, dspec128, din128, dout128); + testVectorCastDoubleToDouble(dspec128, dspec256, din128, dout256); + testVectorCastDoubleToDouble(dspec128, dspec512, din128, dout512); + + testVectorCastDoubleToDouble(dspec256, dspec64, din256, dout64); + testVectorCastDoubleToDouble(dspec256, dspec128, din256, dout128); + testVectorCastDoubleToDouble(dspec256, dspec256, din256, dout256); + testVectorCastDoubleToDouble(dspec256, dspec512, din256, dout512); + + testVectorCastDoubleToDouble(dspec512, dspec64, din512, dout64); + testVectorCastDoubleToDouble(dspec512, dspec128, din512, dout128); + testVectorCastDoubleToDouble(dspec512, dspec256, din512, dout256); + testVectorCastDoubleToDouble(dspec512, dspec512, din512, dout512); + } + } }