[vectorIntrinsics] RFR: 8284459: Add x86 back-end implementation for LEADING and TRAILING ZEROS COUNT operations [v3]

Sandhya Viswanathan sviswanathan at openjdk.java.net
Tue Apr 19 00:05:53 UTC 2022


On Fri, 15 Apr 2022 21:44:53 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Summary of changes:
>> - Patch extends auto-vectorize to vectorize following Java SE APIs.
>>      1) Integer.numberOfLeadingZeros()
>>      2) Long.numberOfLeadingZeros()
>>      3) Integer.numberOfTrailingZeros()
>>      4) Long.numberOfTrailingZeros()
>> 
>> - Adds optimized X86 backend implementation for VectorOperations.LEADING_ZERO_COUNT and VectorOperations.TRAILING_ZEROS_COUNT for AVX512 and legacy targets.
>> 
>> Kindly review and share your feedback.
>> 
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8284459: Adding auto-vectorizer and x86 backend support for TRAILING_ZERO_COUNT, also some code re-organization.

src/hotspot/cpu/x86/stubGenerator_x86_32.cpp line 610:

> 608:     __ emit_data(0x01010101, relocInfo::none, 0);
> 609:     __ emit_data(0x00000000, relocInfo::none, 0);
> 610:     __ emit_data(0x00000000, relocInfo::none, 0);

could be done with a 4 iteration for loop over the following:
    __ emit_data(0x02020304, relocInfo::none, 0);
    __ emit_data(0x01010101, relocInfo::none, 0);
    __ emit_data(0x00000000, relocInfo::none, 0);
    __ emit_data(0x00000000, relocInfo::none, 0);

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp line 809:

> 807:     __ emit_data64(0x0000000000000000, relocInfo::none);
> 808:     __ emit_data64(0x0101010102020304, relocInfo::none);
> 809:     __ emit_data64(0x0000000000000000, relocInfo::none);

could be done with a 4 iteration for loop over the following:
    __ emit_data64(0x0101010102020304, relocInfo::none);
    __ emit_data64(0x0000000000000000, relocInfo::none);

src/hotspot/cpu/x86/x86.ad line 8687:

> 8685: %}
> 8686: 
> 8687: instruct vpopcount_evx_reg(vec dst, vec src, vec xtmp1, vec xtmp2, rRegP rtmp) %{

Typo,  did you mean vpopcount_avx_reg here?

src/hotspot/cpu/x86/x86.ad line 8696:

> 8694:     int opcode = this->ideal_Opcode();
> 8695:     int vlen_enc = vector_length_encoding(this, $src);
> 8696:     BasicType bt = Matcher::vector_element_basic_type(this);

We should be checking the vector_element_basic_type of src instead of this. e.g. for Long vectors producing Int results, we need to pass bt as T_LONG to vector_popcount_integral.

-------------

PR: https://git.openjdk.java.net/panama-vector/pull/189


More information about the panama-dev mailing list