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

Xiaohong Gong xgong at openjdk.java.net
Thu Feb 17 01:54:41 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

Xiaohong Gong has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:

 - Merge branch 'jdk:master' into JDK-8281803
 - 8281803: AArch64: Optimize masked vector NOT/AND_NOT for SVE

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7486/files
  - new: https://git.openjdk.java.net/jdk/pull/7486/files/5475d8f8..ed8a3ccb

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7486&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7486&range=00-01

  Stats: 3109 lines in 69 files changed: 2744 ins; 131 del; 234 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