Hi All,
- The VectorLoadMask IR node converts the raw mask loaded from a boolean[]
(one 0/1 byte per lane) into the form that
predicated operations and mask query operations consume.
- Until now, AVX-512BW targets used a three-instruction sequence:
vpxor to zero a temporary,
vpsubb to negate 0/1 into 0/-1, and
vpmovb2m to move the byte sign bits into an opmask register.
- This patch replaces it with a single
` vptestmb k, src, src, instruction`
which sets one opmask bit for each non-zero byte.
- Because the input lanes are guaranteed to be 0 or 1, the result is identical.
Following are the performance numbers of JMH benchmark included with the patch.
System: AMD EPYC 9996 256-Core Processor (Venice) fixed frequency 2.5Ghz
Baseline:-
Benchmark (size) Mode Cnt Score
Error Units
VectorLoadMaskBenchmark.byteLoadMaskLogic 1024 thrpt 2 26.770
ops/us
VectorLoadMaskBenchmark.byteLoadMaskTrueCount 1024 thrpt 2 93.465
ops/us
VectorLoadMaskBenchmark.intLoadMaskLogic 1024 thrpt 2 7.383
ops/us
VectorLoadMaskBenchmark.intLoadMaskTrueCount 1024 thrpt 2 30.316
ops/us
VectorLoadMaskBenchmark.longLoadMaskLogic 1024 thrpt 2 3.697
ops/us
VectorLoadMaskBenchmark.longLoadMaskTrueCount 1024 thrpt 2 15.016
ops/us
VectorLoadMaskBenchmark.shortLoadMaskLogic 1024 thrpt 2 14.343
ops/us
VectorLoadMaskBenchmark.shortLoadMaskTrueCount 1024 thrpt 2 55.970
ops/us
Withopt:-
Benchmark (size) Mode Cnt Score
Error Units
VectorLoadMaskBenchmark.byteLoadMaskLogic 1024 thrpt 2 30.421
ops/us
VectorLoadMaskBenchmark.byteLoadMaskTrueCount 1024 thrpt 2 101.824
ops/us
VectorLoadMaskBenchmark.intLoadMaskLogic 1024 thrpt 2 8.580
ops/us
VectorLoadMaskBenchmark.intLoadMaskTrueCount 1024 thrpt 2 33.920
ops/us
VectorLoadMaskBenchmark.longLoadMaskLogic 1024 thrpt 2 4.204
ops/us
VectorLoadMaskBenchmark.longLoadMaskTrueCount 1024 thrpt 2 16.027
ops/us
VectorLoadMaskBenchmark.shortLoadMaskLogic 1024 thrpt 2 16.520
ops/us
VectorLoadMaskBenchmark.shortLoadMaskTrueCount 1024 thrpt 2 63.590
ops/us
Kindly review and share your feedback.
Best Regards,
Jatin
---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK
Interim AI Policy](https://openjdk.org/legal/ai).
-------------
Commit messages:
- 8398308: C2: x86: Optimize VectorLoadMask instruction sequence for AVX-512
targets
Changes: https://git.openjdk.org/jdk/pull/34059/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=34059&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8398308
Stats: 156 lines in 3 files changed: 146 ins; 4 del; 6 mod
Patch: https://git.openjdk.org/jdk/pull/34059.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/34059/head:pull/34059
PR: https://git.openjdk.org/jdk/pull/34059