On Wed, 8 Apr 2026 17:09:06 GMT, Jatin Bhateja <[email protected]> wrote:
>> Patch optimizes Vector. slice operation with constant index using x86 ALIGNR
>> instruction.
>> It also adds a new hybrid call generator to facilitate lazy intrinsification
>> or else perform procedural inlining to prevent call overhead and boxing
>> penalties in case the fallback implementation expects to operate over
>> vectors. The existing vector API-based slice implementation is now the
>> fallback code that gets inlined in case intrinsification fails.
>>
>> Idea here is to add infrastructure support to enable intrinsification of
>> fast path for selected vector APIs, else enable inlining of fall-back
>> implementation if it's based on vector APIs. Existing call generators like
>> PredictedCallGenerator, used to handle bi-morphic inlining, already make use
>> of multiple call generators to handle hit/miss scenarios for a particular
>> receiver type. The newly added hybrid call generator is lazy and called
>> during incremental inlining optimization. It also relieves the inline
>> expander to handle slow paths, which can easily be implemented library side
>> (Java).
>>
>> Vector API jtreg tests pass at AVX level 2, remaining validation in progress.
>>
>> Performance numbers:
>>
>>
>> System : 13th Gen Intel(R) Core(TM) i3-1315U
>>
>> Baseline:
>> Benchmark (size) Mode Cnt
>> Score Error Units
>> VectorSliceBenchmark.byteVectorSliceWithConstantIndex1 1024 thrpt 2
>> 9444.444 ops/ms
>> VectorSliceBenchmark.byteVectorSliceWithConstantIndex2 1024 thrpt 2
>> 10009.319 ops/ms
>> VectorSliceBenchmark.byteVectorSliceWithVariableIndex 1024 thrpt 2
>> 9081.926 ops/ms
>> VectorSliceBenchmark.intVectorSliceWithConstantIndex1 1024 thrpt 2
>> 6085.825 ops/ms
>> VectorSliceBenchmark.intVectorSliceWithConstantIndex2 1024 thrpt 2
>> 6505.378 ops/ms
>> VectorSliceBenchmark.intVectorSliceWithVariableIndex 1024 thrpt 2
>> 6204.489 ops/ms
>> VectorSliceBenchmark.longVectorSliceWithConstantIndex1 1024 thrpt 2
>> 1651.334 ops/ms
>> VectorSliceBenchmark.longVectorSliceWithConstantIndex2 1024 thrpt 2
>> 1642.784 ops/ms
>> VectorSliceBenchmark.longVectorSliceWithVariableIndex 1024 thrpt 2
>> 1474.808 ops/ms
>> VectorSliceBenchmark.shortVectorSliceWithConstantIndex1 1024 thrpt 2
>> 10399.394 ops/ms
>> VectorSliceBenchmark.shortVectorSliceWithConstantIndex2 1024 thrpt 2
>> 10502.894 ops/ms
>> VectorSliceB...
>
> Jatin Bhateja has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Review comments resolution
src/hotspot/cpu/x86/assembler_x86.cpp line 6779:
> 6777: void Assembler::vpalignr(XMMRegister dst, XMMRegister nds, XMMRegister
> src, int imm8, int vector_len) {
> 6778: assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit ||
> (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), "");
> 6779: assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(),
> "");
The AVX2 check for 256 bit should be retained.
assert(vector_len == AVX_128bit? VM_Version::supports_avx() :
vector_len == AVX_256bit? VM_Version::supports_avx2() :
vector_len == AVX_512bit? VM_Version::supports_avx512bw(), "");
The higher bank xmm usage for < 512 bit vl is already covered by the
_legacy_mode_bw in the attributes. The asserts in
Assembler::vex_prefix_and_encode() check for xmm registers to be 0-15 in such
case.
src/hotspot/cpu/x86/x86.ad line 25446:
> 25444: %}
> 25445:
> 25446: instruct vector_slice_const_origin_GT16B_index_multiple4_reg_evex(vec
> dst, vec src1, vec src2, immI origin)
A nit: Why do we refer to vector length as index? Also since multiple4 applies
to origin, would read better if that goes right after origin and before
G16B_index.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24104#discussion_r3067037113
PR Review Comment: https://git.openjdk.org/jdk/pull/24104#discussion_r3067171045