Skip to content

Commit

Permalink
8338124: C2 SuperWord: MulAddS2I input permutation still partially br…
Browse files Browse the repository at this point in the history
…oken after JDK-8333840

Reviewed-by: chagedorn, thartmann, kvn
  • Loading branch information
eme64 committed Aug 13, 2024
1 parent 73ddb7d commit c27a8c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/superword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class TestMulAddS2I {
static final int[] GOLDEN_J;
static final int[] GOLDEN_K;
static final int[] GOLDEN_L;
static final int[] GOLDEN_M;

static {
for (int i = 0; i < RANGE; i++) {
Expand All @@ -71,6 +72,7 @@ public class TestMulAddS2I {
GOLDEN_J = testj(new int[ITER]);
GOLDEN_K = testk(new int[ITER]);
GOLDEN_L = testl(new int[ITER]);
GOLDEN_M = testm(new int[ITER]);
}


Expand All @@ -80,7 +82,7 @@ public static void main(String[] args) {
}

@Run(test = {"testa", "testb", "testc", "testd", "teste", "testf", "testg", "testh",
"testi", "testj", "testk", "testl"})
"testi", "testj", "testk", "testl", "testm"})
@Warmup(0)
public static void run() {
compare(testa(), GOLDEN_A, "testa");
Expand All @@ -95,6 +97,7 @@ public static void run() {
compare(testj(new int[ITER]), GOLDEN_J, "testj");
compare(testk(new int[ITER]), GOLDEN_K, "testk");
compare(testl(new int[ITER]), GOLDEN_L, "testl");
compare(testm(new int[ITER]), GOLDEN_M, "testm");
}

public static void compare(int[] out, int[] golden, String name) {
Expand Down Expand Up @@ -299,4 +302,17 @@ public static int[] testl(int[] out) {
return out;
}

@Test
@IR(counts = {IRNode.MUL_ADD_S2I, "> 0"},
applyIfCPUFeatureOr = {"sse2", "true", "asimd", "true"})
@IR(counts = {IRNode.MUL_ADD_VS2VI, "= 0"})
public static int[] testm(int[] out) {
for (int i = 0; i < ITER-4; i+=4) {
// Unrolled, with some swaps that prevent vectorization.
out[i+0] += ((sArr1[2*i+0] * sArr2[2*i+1]) + (sArr1[2*i+1] * sArr2[2*i+0])); // bad
out[i+1] += ((sArr1[2*i+2] * sArr2[2*i+2]) + (sArr1[2*i+3] * sArr2[2*i+3])); // ok
// 2-element gap
}
return out;
}
}

0 comments on commit c27a8c8

Please sign in to comment.