I found this during the work of JDK-8302139.
See example Test.java
./java -XX:-TieredCompilation -Xbatch -XX:CompileCommand=compileonly,Test::test -XX:+TraceSuperWord Test.java
static int test(int[] data) {
int res = 1;
for (int i = 2; i < N-2; i++) {
int v = data[i] * 11;
res = Math.min(res, v);
}
return res;
}
In TraceSuperWord, we can see that it tries to vectorize.
find_adjacent_refs: we detect the LoadI
extend_packlist: we extend to the MulI, but unfortunately not the MinI
combine_packs: combines the LoadI and MulI (we are missing the MinI)
filter_packs: rejects the whole vectorization because the MinI were not put in a pack, now the MulI has a non-vectorized use in the loop.
A first analysis showed that maybe something with the order of the MinI is unexpected.
Maybe the inputs of the min / max get flipped, and it does not get detected correctly in SuperWord::reduction(Node* s1, Node* s2)
This is both for Math.min and Math.max.
The same example with float array does already vectorize.
Double does not vectorize because of this issue: JDK-8300865
For long it did not even try to vectorize with SuperWord. Maybe because of this line in x86.ad:
} else if (bt == T_LONG && (UseAVX < 3 || !VM_Version::supports_avx512vlbwdq())) {
Yeah, probably. I have AVX512 on my laptop, but avx512vlbwdq is missing. So it would have to be tested on a machine that has that hardware support.