[vectorIntrinsics] RFR: 8283709: Add x86 back-end implementation for bit BIT_COUNT operation [v9]
Sandhya Viswanathan
sviswanathan at openjdk.java.net
Mon Apr 11 21:47:07 UTC 2022
On Mon, 11 Apr 2022 10:58:39 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> Summary of changes:
>>
>> - Patch re-uses existing C2 IR nodes and re-organizes LUT based JIT code sequence of VectorOperations.BIT_COUNT operation
>> for sub-word type (BYTE, SHORT) vectors over X86 targets supporting AVA2 and AVX512 features.
>> - Efficient single instruction POPCOUNT instruction is emitted for applicable targets.
>>
>> Kindly review and share you feedback.
>>
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
>
> 8283709: Review comments resolved.
Please make the changes suggested here. No need for re-review.
src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 4541:
> 4539: KRegister mask, bool merge, int vec_enc) {
> 4540: assert(VM_Version::supports_avx512vl() || vec_enc == Assembler::AVX_512bit, "");
> 4541: assert(UsePopCountInstruction, "");
Please remove this assert on UsePopCountInstruction.
src/hotspot/cpu/x86/stubGenerator_x86_32.cpp line 4127:
> 4125: StubRoutines::x86::_vector_reverse_byte_perm_mask_short = generate_vector_reverse_byte_perm_mask_short("perm_mask_short");
> 4126:
> 4127: if (VM_Version::supports_avx2() && (!VM_Version::supports_avx512_vpopcntdq() || !UsePopCountInstruction)) {
Please remove the reference to UsePopCountInstruction here.
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp line 7795:
> 7793: StubRoutines::x86::_vector_reverse_byte_perm_mask_short = generate_vector_reverse_byte_perm_mask_short("perm_mask_short");
> 7794:
> 7795: if (VM_Version::supports_avx2() && (!VM_Version::supports_avx512_vpopcntdq() || !UsePopCountInstruction)) {
Please remove the reference to UsePopCountInstruction here.
src/hotspot/cpu/x86/vm_version_x86.cpp line 1705:
> 1703:
> 1704: // Use population count instruction if available.
> 1705: if (supports_popcnt() || supports_avx512_vpopcntdq() || supports_avx512_bitalg()) {
The UsePopCountInstruction is only for scalar popcont. Extending it to Vector popcount is causing lot of confustion. Let us keep it for scalar only as below:
if (supports_popcnt()) {
...
}
src/hotspot/cpu/x86/x86.ad line 8635:
> 8633: VM_Version::supports_avx512_bitalg()) ||
> 8634: (is_non_subword_integral_type(Matcher::vector_element_basic_type(n->in(1))) &&
> 8635: VM_Version::supports_avx512_vpopcntdq())));
Please replace by:
predicate(is_pop_count_instr_target(Matcher::vector_element_basic_type(n->in(1))));
Also no need to check for UsePopCountInstruction any where as it is only meant for scalar popcount.
src/hotspot/cpu/x86/x86.ad line 8660:
> 8658: VM_Version::supports_avx512_bitalg()) ||
> 8659: (is_non_subword_integral_type(Matcher::vector_element_basic_type(n->in(1))) &&
> 8660: VM_Version::supports_avx512_vpopcntdq())));
Could be replaced by:
predicate(is_pop_count_instr_target(Matcher::vector_element_basic_type(n->in(1))));
Also no need to check for UsePopCountInstruction any where as it is only meant for scalar popcount.
src/hotspot/cpu/x86/x86.ad line 8677:
> 8675: predicate(!UsePopCountInstruction ||
> 8676: (!VM_Version::supports_avx512_vpopcntdq() && Matcher::vector_element_basic_type(n->in(1)) == T_INT) ||
> 8677: (!VM_Version::supports_avx512_bitalg() && is_subword_type(Matcher::vector_element_basic_type(n->in(1)))));
Could be replaced by:
predicate((Matcher::vector_element_basic_type(n->in(1)) != T_LONG)
&& !is_pop_count_instr_target(Matcher::vector_element_basic_type(n->in(1))));
src/hotspot/cpu/x86/x86.ad line 8691:
> 8689:
> 8690: instruct vpopcountL_avx_reg(vec dst, vec src, vec xtmp1, vec xtmp2, vec xtmp3, rRegP rtmp) %{
> 8691: predicate(!UsePopCountInstruction || !VM_Version::supports_avx512_vpopcntdq());
Please remove the reference to UsePopCountInstruction here.
-------------
Marked as reviewed by sviswanathan (Committer).
PR: https://git.openjdk.java.net/panama-vector/pull/185
More information about the panama-dev
mailing list