JDK-8340010 : Fix vectorization tests with compact headers
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2024-09-12
  • Updated: 2024-11-28
  • Resolved: 2024-11-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b26Fixed
Related Reports
Blocks :  
Relates :  
Description
In JDK-8305895, the following tests have some disabled sub-tests:

test/hotspot/jtreg/compiler/loopopts/superword/TestAlignVector.java
test/hotspot/jtreg/compiler/loopopts/superword/TestMulAddS2I.java

Some tests are failing with UseCompactObjectHeaders, but only with UseSSE<=3:

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationNotRun.java
test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java
test/hotspot/jtreg/compiler/vectorization/runner/LoopCombinedOpTest.java

I think the issue with all of them is that vectorization in those scenarios only works when the operations inside the loop start at an array index that addresses an element at 8-byte-aligned offset.

We could either improve the tests to run with different loop indices, or -  even better - improve vectorization, if this is possible.
Comments
Changeset: 811d08c0 Branch: master Author: Emanuel Peter <epeter@openjdk.org> Date: 2024-11-25 10:39:36 +0000 URL: https://git.openjdk.org/jdk/commit/811d08c0a4e0da55f306686423aec40d29fabf00
25-11-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22199 Date: 2024-11-18 10:32:44 +0000
21-11-2024

[~epeter] Some related code may have changed while we reviewed the big PR, maybe? Not sure. I am not sure if we care much about AlignVector and UseCompactObjectHeaders. Can it be made that vectorization does not work in those mixed scenarios but does work when both arrays are aligned? Or maybe it already works that way? There is work in progress to make the object header even more compact, down to 4 bytes. This would bring alignment for all types back to the same value: all object fields and array elements would then start at offset 8. This would solve this problem, I think. However, I am not sure if and when this would go into upstream JDK, so we might need to live with a compromise for a couple of releases. WDYT?
18-11-2024

Some are now broken, i.e. fail with: -XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders -XX:+AlignVector We must not have tested it well enough [~rkennke]. These cases are a little worrying: they happen with mixed types. The problem is often that the two data-types cannot both be aligned. If we enable AlignVector, we need 8-byte alignment. But the two addresses cannot be both aligned at the same time. Example: byte[] adr = base + 12 + 1*i i % 8 = 4 int[] adr = base + 12 + 4*i i % 2 = 1 There is no solution for "i % 8 = 4" and "i % 2 = 1". So we cannot vectorize both in an aligned way! Now I wonder: do we ever want to enable both UseCompactObjectHeaders and AlignVector? Probably yes? That said: Oracle does not super care about AlignVector, all machines I have seen don't need it enabled. compiler/vectorization/runner/ArrayTypeConvertTest.java Failed IR Rules (3) of Methods (3) ---------------------------------- 1) Method "public char[] compiler.vectorization.runner.ArrayTypeConvertTest.convertFloatToChar()" - [Failed IR rules: 1]: * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={"asimd", "true", "avx2", "true"}, counts={"_#V#VECTOR_CAST_F2S#_", "_@min(max_float, max_char)", ">0"}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})" > Phase "PrintIdeal": - counts: Graph contains wrong number of nodes: * Constraint 1: "(\\d+(\\s){2}(VectorCastF2X.*)+(\\s){2}===.*vector[A-Za-z]<S,16>)" - Failed comparison: [found] 0 > 0 [given] - No nodes matched! 2) Method "public short[] compiler.vectorization.runner.ArrayTypeConvertTest.convertFloatToShort()" - [Failed IR rules: 1]: * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={"asimd", "true", "avx2", "true"}, counts={"_#V#VECTOR_CAST_F2S#_", "_@min(max_float, max_short)", ">0"}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})" > Phase "PrintIdeal": - counts: Graph contains wrong number of nodes: * Constraint 1: "(\\d+(\\s){2}(VectorCastF2X.*)+(\\s){2}===.*vector[A-Za-z]<S,16>)" - Failed comparison: [found] 0 > 0 [given] - No nodes matched! 3) Method "public float[] compiler.vectorization.runner.ArrayTypeConvertTest.convertShortToFloat()" - [Failed IR rules: 1]: * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={"asimd", "true", "avx2", "true"}, counts={"_#V#VECTOR_CAST_S2F#_", "_@min(max_short, max_float)", ">0"}, applyIfPlatform={}, applyIfPlatformOr={}, failOn={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})" > Phase "PrintIdeal": - counts: Graph contains wrong number of nodes: * Constraint 1: "(\\d+(\\s){2}(VectorCastS2X.*)+(\\s){2}===.*vector[A-Za-z]<F,16>)" - Failed comparison: [found] 0 > 0 [given] - No nodes matched! compiler/vectorization/runner/LoopCombinedOpTest.java Failed IR Rules (1) of Methods (1) ---------------------------------- 1) Method "public int[] compiler.vectorization.runner.LoopCombinedOpTest.manuallyUnrolledStride2()" - [Failed IR rules: 1]: * @IR rule 1: "@compiler.lib.ir_framework.IR(phase={DEFAULT}, applyIfPlatformAnd={}, applyIfCPUFeatureOr={"asimd", "true", "sse4.1", "true"}, counts={"_#STORE_VECTOR#_", ">0"}, failOn={}, applyIfPlatform={}, applyIfPlatformOr={}, applyIfOr={}, applyIfCPUFeatureAnd={}, applyIf={}, applyIfCPUFeature={}, applyIfAnd={}, applyIfNot={})" > Phase "PrintIdeal": - counts: Graph contains wrong number of nodes: * Constraint 1: "(\\d+(\\s){2}(StoreVector.*)+(\\s){2}===.*)" - Failed comparison: [found] 0 > 0 [given] - No nodes matched!
18-11-2024

It turns out that this test has not been caused by UseCompactObjectHeaders: test/hotspot/jtreg/compiler/loopopts/superword/TestSplitPacks.java
02-10-2024

Other tests with disabled sub-tests in JDK-8305895: - test/hotspot/jtreg/compiler/loopopts/superword/TestSplitPacks.java
27-09-2024

ILW = Test failures due to missed vectorization opportunity/possible performance regression, two tests/multiple cases after JDK-8305895, no workaround = MLH = P4
13-09-2024