RFR: 8303762: Optimize vector slice operation with constant index using VPALIGNR instruction [v13]
Quan Anh Mai
qamai at openjdk.org
Mon Feb 16 14:09:23 UTC 2026
On Mon, 9 Feb 2026 21:36:16 GMT, Jatin Bhateja <jbhateja at openjdk.org> 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 with a new target base due to a merge or a rebase. The pull request now contains 16 commits:
>
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8303762
> - Review comments resolutions
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8303762
> - Review comments resolutions
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8303762
> - Update callGenerator.hpp copyright year
> - Review comments resolution
> - Cleanups
> - Review comments resolutions
> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8303762
> - ... and 6 more: https://git.openjdk.org/jdk/compare/ffb6279c...1dfff558
I still think it is not a good solution to add an intrinsic method for this operation. We should add constant info to `TypeVect` and transform the slice pattern into `VectorSliceNode`. I think it is adequate to add bit info (zeros and ones) to each `TypeVect` instance so that we can do decent inference without too much additional memory overhead.
src/hotspot/share/opto/callGenerator.cpp line 703:
> 701: // Attempt inlining fallback implementation in case of
> 702: // intrinsification failure.
> 703: if (new_jvms == nullptr && is_vector_late_inline()) {
This may be problematic if the intrinsification does not succeed because the arguments have not been constant-folded. It is because the order in which methods are processed during incremental inline is not deterministic.
-------------
PR Review: https://git.openjdk.org/jdk/pull/24104#pullrequestreview-3808805022
PR Review Comment: https://git.openjdk.org/jdk/pull/24104#discussion_r2812585102
More information about the core-libs-dev
mailing list