RFR: 8368722: Vector API intrinsics enabled wrongly on platforms without support for misaligned vector access [v3]

Fei Yang fyang at openjdk.org
Fri Oct 10 02:52:02 UTC 2025


On Thu, 9 Oct 2025 09:04:35 GMT, Dingli Zhang <dzhang at openjdk.org> wrote:

>> Hi,
>> Can you help to review this patch? Thanks!
>> 
>> In `*VectorLoadStoreTests.java`,  `loadMemorySegmentMaskIOOBE` and `storeMemorySegmentMaskIOOBE` may fail because `int index = fi.apply((int) a.byteSize())` can generate random indices that result in misaligned addresses, leading to SIGBUS on hardware that disallows misaligned vector accesses.
>> 
>> Some RISC-V hardware supports fast misaligned scalar accesses but not vector ones, which causes SIGBUS when executing these tests with misaligned vector memory operations.
>> 
>> After [JDK-8368732](https://bugs.openjdk.org/browse/JDK-8368732), we can use `AlignVector` to check the result on platforms with or without fast misaligned vector accesses. When misaligned vector accesses are not supported, it is possible to completely disable the VM’s VectorAPI support by setting `EnableVectorSupport`, without affecting auto-vectorization.
>> 
>> In addition, after running fastdebug tests including `jdk_vector, jdk_vector_sanity, hotspot_vector_1, hotspot_vector_2, compiler/vectorapi, compiler/vectorization`, we found that some IR-related tests require EnableVectorSupport. Therefore, we added `@requires vm.opt.EnableVectorSupport == true` to skip these tests.
>> 
>> We can check the status of EnableVectorSupport as follows:
>> 
>> On k1
>> $ java --add-modules=jdk.incubator.vector -Xlog:compilation -version
>> [0.737s][info][compilation] EnableVectorSupport=false
>> [0.738s][info][compilation] EnableVectorReboxing=false
>> [0.738s][info][compilation] EnableVectorAggressiveReboxing=false
>> 
>> On qemu
>> $ java --add-modules=jdk.incubator.vector -Xlog:compilation -version
>> [3.048s][info][compilation] EnableVectorSupport=true
>> [3.050s][info][compilation] EnableVectorReboxing=true
>> [3.051s][info][compilation] EnableVectorAggressiveReboxing=true
>> 
>> 
>> ### Test (fastdebug)
>> - [x] Run jdk_vector, jdk_vector_sanity, hotspot_vector_1, hotspot_vector_2, compiler/vectorapi, compiler/vectorization on k1
>
> Dingli Zhang 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 three additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'upstream/master' into JDK-8368722-20251009
>  - Add supports_misaligned_vector_accesses
>  - 8368722: RISC-V: Several vector load/store tests fail without support for misaligned vector access

Mind you that the following tests explicitly are testing `-XX:-AlignVector` and won't work on hardware platforms without misaligned vector. But it doesn't seem to me reasonable to add a requirement like `@requires vm.opt.EnableVectorSupport == true` for them as they are superword tests. These tests were once enabled for RISC-V by: https://bugs.openjdk.org/browse/JDK-8352529. Maybe we should simply keep them disabled for this platform?


TEST: compiler/loopopts/superword/TestAlignVector.java#NoAlignVector
TEST: compiler/loopopts/superword/TestAlignVector.java#NoAlignVector-COH
TEST: compiler/loopopts/superword/TestAliasingFuzzer.java#random-flags
TEST: compiler/loopopts/superword/TestMemorySegment_8365982.java
TEST: compiler/c2/irTests/TestVectorizationNotRun.java
TEST: compiler/c2/irTests/TestVectorizationMismatchedAccess.java

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

PR Comment: https://git.openjdk.org/jdk/pull/27506#issuecomment-3388091546


More information about the hotspot-dev mailing list