Skip to content

Commit 67d6f3c

Browse files
committed
8332905: C2 SuperWord: bad AD file, with RotateRightV and first operand not a pack
Reviewed-by: chagedorn, thartmann
1 parent ca30726 commit 67d6f3c

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/hotspot/share/opto/superword.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2435,7 +2435,7 @@ bool SuperWord::output() {
24352435
vn = StoreVectorNode::make(opc, ctl, mem, adr, atyp, val, vlen);
24362436
vlen_in_bytes = vn->as_StoreVector()->memory_size();
24372437
} else if (VectorNode::is_scalar_rotate(n)) {
2438-
Node* in1 = first->in(1);
2438+
Node* in1 = vector_opd(p, 1);
24392439
Node* in2 = first->in(2);
24402440
// If rotation count is non-constant or greater than 8bit value create a vector.
24412441
if (!in2->is_Con() || !Matcher::supports_vector_constant_rotates(in2->get_int())) {

test/hotspot/jtreg/compiler/vectorization/runner/ArrayShiftOpTest.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/*
2525
* @test
26+
* @bug 8183390 8332905
2627
* @summary Vectorization test on bug-prone shift operation
2728
* @library /test/lib /
2829
*
@@ -48,6 +49,7 @@
4849
public class ArrayShiftOpTest extends VectorizationTestRunner {
4950

5051
private static final int SIZE = 543;
52+
private static int size = 543;
5153

5254
private int[] ints;
5355
private long[] longs;
@@ -71,7 +73,7 @@ public ArrayShiftOpTest() {
7173
}
7274

7375
@Test
74-
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512f", "true"},
76+
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"},
7577
counts = {IRNode.STORE_VECTOR, ">0"})
7678
@IR(applyIfCPUFeature = {"avx512f", "true"},
7779
counts = {IRNode.ROTATE_RIGHT_V, ">0"})
@@ -87,7 +89,23 @@ public int[] intCombinedRotateShift() {
8789
}
8890

8991
@Test
90-
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx512f", "true"},
92+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
93+
counts = {IRNode.STORE_VECTOR, ">0"})
94+
@IR(applyIfCPUFeature = {"avx512f", "true"},
95+
counts = {IRNode.ROTATE_RIGHT_V, ">0"})
96+
// Requires size to not be known at compile time, otherwise the shift
97+
// can get constant folded with the (iv + const) pattern from the
98+
// PopulateIndex.
99+
public int[] intCombinedRotateShiftWithPopulateIndex() {
100+
int[] res = new int[size];
101+
for (int i = 0; i < size; i++) {
102+
res[i] = (i << 14) | (i >>> 18);
103+
}
104+
return res;
105+
}
106+
107+
@Test
108+
@IR(applyIfCPUFeatureOr = {"asimd", "true", "avx2", "true"},
91109
counts = {IRNode.STORE_VECTOR, ">0"})
92110
@IR(applyIfCPUFeature = {"avx512f", "true"},
93111
counts = {IRNode.ROTATE_RIGHT_V, ">0"})

0 commit comments

Comments
 (0)