On Sat, 7 Nov 2026 00:35:17 GMT, Jatin Bhateja <[email protected]> wrote:
>> Hi All,
>>
>> x86 AVX-512 targets provides packed shifts for 16, 32, and 64-bit lanes, but
>> not for bytes. C2 lowers LShiftVB, RShiftVB, and URShiftVB by widening bytes
>> to words, shifting, masking, and packing. That sequence is the byte-shift
>> bottleneck.
>>
>> GFNI **gf2p8affineqb** instruction applies one 8×8 bit matrix to every byte.
>> Logical left, logical right, and arithmetic right shifts by 0..7 are fixed
>> matrices derived from the identity 0x0102040810204080.
>>
>> Patch uses this lowering for 128-, 256-, and 512-bit vectors when GFNI is
>> available and keeps the existing widen/shift/pack path when GFNI is absent.
>>
>> Following are the performance numbers of benchmark included with the patch.
>>
>> System: AMD EPYC 9755 128-Core Processor (Turin) Fixed frequency 2.5Ghz
>>
>> Baseline:-
>> ----------
>> Benchmark (shift) Mode Cnt Score Error
>> Units
>> ByteShiftBenchmark.ashr128 3 thrpt 2 24994.026
>> ops/us
>> ByteShiftBenchmark.ashr256 3 thrpt 2 29289.608
>> ops/us
>> ByteShiftBenchmark.ashr512 3 thrpt 2 39944.806
>> ops/us
>> ByteShiftBenchmark.autoVecAshr 3 thrpt 2 32592.174
>> ops/us
>> ByteShiftBenchmark.autoVecLshl 3 thrpt 2 30668.901
>> ops/us
>> ByteShiftBenchmark.lshl128 3 thrpt 2 25247.149
>> ops/us
>> ByteShiftBenchmark.lshl256 3 thrpt 2 27345.375
>> ops/us
>> ByteShiftBenchmark.lshl512 3 thrpt 2 38500.755
>> ops/us
>> ByteShiftBenchmark.lshr128 3 thrpt 2 25081.398
>> ops/us
>> ByteShiftBenchmark.lshr256 3 thrpt 2 28272.477
>> ops/us
>> ByteShiftBenchmark.lshr512 3 thrpt 2 42186.028
>> ops/us
>>
>> Withopt:-
>> ---------
>> Benchmark (shift) Mode Cnt Score Error
>> Units
>> ByteShiftBenchmark.ashr128 3 thrpt 2 31313.173
>> ops/us
>> ByteShiftBenchmark.ashr256 3 thrpt 2 58663.746
>> ops/us
>> ByteShiftBenchmark.ashr512 3 thrpt 2 50472.509
>> ops/us
>> ByteShiftBenchmark.autoVecAshr 3 thrpt 2 44965.109
>> ops/us
>> ByteShiftBenchmark.autoVecLshl 3 thrpt 2 46304.515
>> ops/us
>> ByteShiftBenchmark.lshl128 3 thrpt 2 28849.321
>> ops/us
>> ByteShiftBenchmark.lshl256 3 thrpt 2 40492.534
>> ops/us
>> ByteShiftBenchmark.lshl512 3 t...
>
> Jatin Bhateja has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Fix stack management by adding popf after cmpl
src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 1436:
> 1434: pushf();
> 1435: cmpl(rtmp, 31);
> 1436: jccb(Assembler::belowEqual, count_in_range);
stop() generates a lot of code. This should be jcc instead of jccb. Needed for
UseAPX with -XX:+ShowMessageBoxOnError.
test/hotspot/jtreg/compiler/vectorapi/TestGFNIUniformByteShift.java line 51:
> 49: * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=0
> ${test.main.class}
> 50: * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=1
> ${test.main.class}
> 51: * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=2
> ${test.main.class}
Good to move these 3 into separate test block along with:
`@requires os.arch == "amd64" | os.arch == "x86_64"`
Also these should be written in the form:
`@run driver ${test.main.class} -XX:UseAVX=0`
This is needed to pass the command line options to the test JVM, otherwise only
driver gets the options.
test/hotspot/jtreg/compiler/vectorapi/TestGFNIUniformByteShift.java line 86:
> 84: testFramework.setDefaultWarmup(10000)
> 85: .addFlags("--add-modules=jdk.incubator.vector")
> 86: .start();
Need to add:
.addFlags(args)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/33113#discussion_r4558145074
PR Review Comment: https://git.openjdk.org/jdk/pull/33113#discussion_r4558127138
PR Review Comment: https://git.openjdk.org/jdk/pull/33113#discussion_r4558100659