JDK-8333840 attempted to fix some input permutation cases. Sadly, there is a typo which means that there can still be some broken cases that produce wrong results.
This patch should fix it:
diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp
index 0e1328a4485..5b420487b06 100644
--- a/src/hotspot/share/opto/superword.cpp
+++ b/src/hotspot/share/opto/superword.cpp
@@ -2272,7 +2272,7 @@ Node_List* PackSet::strided_pack_input_at_index_or_null(const Node_List* pack, c
return nullptr; // size mismatch
}
- for (uint i = 1; i < pack->size(); i++) {
+ for (uint i = 0; i < pack->size(); i++) {
if (pack->at(i)->in(index) != pack_in->at(i * stride + offset)) {
return nullptr; // use-def mismatch
}
-----------------------
Reproduce with (passes with -Xint):
java Test1b.java
We can see that it vectorizes (even though it should not):
./java -XX:CompileCommand=printcompilation,Test1::* -XX:CompileCommand=compileonly,Test1b::test -Xbatch -XX:+TraceNewVectors Test1b.java
Result:
Exception in thread "main" java.lang.RuntimeException: errors: 2032
at Test1b.compare(Test1b.java:41)
at Test1b.main(Test1b.java:20)