This must be a relatively new regression, I think it does not affect JDK20, but certainly the newest of JDK22 and also JDK-22-ea+15-1134.
./java -XX:CompileCommand=compileonly,Test22::test22 -XX:CompileCommand=printcompilation,Test22::test* -XX:LoopUnrollLimit=250 -XX:UseAVX=2 -Xbatch -XX:+TraceSuperWord -XX:+TraceLoopOpts -XX:LoopMaxUnroll=8 Test22.java
You get:
Exception in thread "main" java.lang.RuntimeException: bad a
at Test22.verify(Test22.java:40)
at Test22.main(Test22.java:26)
But with "-Xint", there is no such exception.
I have a similar example, which also uses Unsafe:
./java -XX:CompileCommand=compileonly,Test21::test21 -XX:CompileCommand=printcompilation,Test21::test* -XX:LoopUnrollLimit=250 --add-modules java.base --add-exports java.base/jdk.internal.misc=ALL-UNNAMED -XX:UseAVX=2 -Xbatch -XX:+TraceSuperWord Test21.java
You get:
Exception in thread "main" java.lang.RuntimeException: bad 18
at Test21.main(Test21.java:28)
But again, we have no exception with "-Xint".