RFR: 8281803: AArch64: Optimize masked vector NOT/AND_NOT for SVE

Xiaohong Gong xgong at openjdk.java.net
Thu Feb 17 01:46:05 UTC 2022


On Wed, 16 Feb 2022 09:20:46 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> Currently the vector lanewise `NOT` is implemented with `"v.xor(-1)"` and `AND_NOT ` is implemented with `"v1.and(v2.xor(-1))"`. With SVE they can be respectively implemented with `"not/bic"` instructions, and we have already optimized the non-masked operations before (see [1]).
>> 
>> Consider the SVE also supports the `predicated` `"not/bic"`, we can apply the same optimizations for the masked `NOT/AND_NOT` by adding match rules. So this patch adds the rules for the following optimizations:
>> 
>> For `NOT `with int type:
>> 
>>   mov z16.s, #-1
>>   eor z18.s, p0/m, z18.s, z16.s  ==>  not z18.s, p0/m, z18.s
>> 
>> For `AND_NOT `with int type:
>> 
>>   not z16.d, p7/m, z16.d
>>   and z17.s, p0/m, z17.s, z16.s  ==>  bic z17.s, p0/m, z16.s
>> 
>> Here is the performance gain for the `"NOT/AND_NOT"` benchmarks (see [2][3] for byte type) with SVE 512-bit:
>> 
>> Benchmark                    Gain
>> LongMaxVector.NOTMasked      1.005
>> ShortMaxVector.NOTMasked     1.017
>> IntMaxVector.NOTMasked       1.022
>> ByteMaxVector.NOTMasked      1.023
>> LongMaxVector.AND_NOTMasked  1.063
>> IntMaxVector.AND_NOTMasked   1.047
>> ShortMaxVector.AND_NOTMasked 1.059
>> ByteMaxVector.AND_NOTMasked  1.030
>> 
>> [1] https://github.com/openjdk/jdk/pull/3370
>> [2] https://github.com/openjdk/panama-vector/blob/vectorIntrinsics/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteMaxVector.java#L1963
>> [3] https://github.com/openjdk/panama-vector/blob/vectorIntrinsics/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteMaxVector.java#L362
>
> Marked as reviewed by aph (Reviewer).

Thanks for the review @theRealAph !

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

PR: https://git.openjdk.java.net/jdk/pull/7486


More information about the hotspot-compiler-dev mailing list