RFR: 8281803: AArch64: Optimize masked vector NOT/AND_NOT for SVE
Xiaohong Gong
xgong at openjdk.java.net
Wed Feb 16 02:29:25 UTC 2022
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
-------------
Commit messages:
- 8281803: AArch64: Optimize masked vector NOT/AND_NOT for SVE
Changes: https://git.openjdk.java.net/jdk/pull/7486/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7486&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8281803
Stats: 198 lines in 5 files changed: 116 ins; 0 del; 82 mod
Patch: https://git.openjdk.java.net/jdk/pull/7486.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/7486/head:pull/7486
PR: https://git.openjdk.java.net/jdk/pull/7486
More information about the hotspot-compiler-dev
mailing list