Skip to content

Commit a02d65e

Browse files
committed
8310308: IR Framework: check for type and size of vector nodes
Reviewed-by: chagedorn, thartmann
1 parent dff99f7 commit a02d65e

File tree

70 files changed

+3498
-2068
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3498
-2068
lines changed

test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class TestMinMaxSubword {
6161
// as Java APIs for Math.min/max do not support integer subword types and superword
6262
// should not generate vectorized Min/Max nodes for them.
6363
@Test
64-
@IR(failOn = {IRNode.MIN_V})
64+
@IR(failOn = {IRNode.MIN_VI, IRNode.MIN_VF, IRNode.MIN_VD})
6565
public static void testMinShort() {
6666
for (int i = 0; i < LENGTH; i++) {
6767
sb[i] = (short) Math.min(sa[i], val);
@@ -77,7 +77,7 @@ public static void testMinShort_runner() {
7777
}
7878

7979
@Test
80-
@IR(failOn = {IRNode.MAX_V})
80+
@IR(failOn = {IRNode.MAX_VI, IRNode.MAX_VF, IRNode.MAX_VD})
8181
public static void testMaxShort() {
8282
for (int i = 0; i < LENGTH; i++) {
8383
sb[i] = (short) Math.max(sa[i], val);
@@ -92,7 +92,7 @@ public static void testMaxShort_runner() {
9292
}
9393

9494
@Test
95-
@IR(failOn = {IRNode.MIN_V})
95+
@IR(failOn = {IRNode.MIN_VI, IRNode.MIN_VF, IRNode.MIN_VD})
9696
public static void testMinByte() {
9797
for (int i = 0; i < LENGTH; i++) {
9898
bb[i] = (byte) Math.min(ba[i], val);
@@ -108,7 +108,7 @@ public static void testMinByte_runner() {
108108
}
109109

110110
@Test
111-
@IR(failOn = {IRNode.MAX_V})
111+
@IR(failOn = {IRNode.MAX_VI, IRNode.MAX_VF, IRNode.MAX_VD})
112112
public static void testMaxByte() {
113113
for (int i = 0; i < LENGTH; i++) {
114114
bb[i] = (byte) Math.max(ba[i], val);

test/hotspot/jtreg/compiler/c2/irTests/TestAutoVecCountingDownLoop.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static void main(String[] args) {
4646

4747

4848
@Test
49-
@IR(counts = {IRNode.LOAD_VECTOR, " >0 "})
49+
@IR(counts = {IRNode.LOAD_VECTOR_I, " >0 "})
5050
@IR(counts = {IRNode.STORE_VECTOR, " >0 "})
5151
private static void testCountingDown(int[] a, int[] b) {
5252
for (int i = 2000; i > 0; i--) {

test/hotspot/jtreg/compiler/c2/irTests/TestAutoVectorization2DArray.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ public static void main(String[] args) {
4848
}
4949

5050
@Test
51-
@IR(counts = { IRNode.LOAD_VECTOR, " >0 " })
52-
@IR(counts = { IRNode.ADD_VD, " >0 " })
53-
@IR(counts = { IRNode.STORE_VECTOR, " >0 " })
51+
// Given small iteration count, the unrolling factor is not very predictable,
52+
// hence it is difficult to exactly predict the vector size. But let's at least
53+
// check that there is some vectorization of any size.
54+
@IR(counts = { IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE_ANY, " >0 " })
55+
@IR(counts = { IRNode.ADD_VD, IRNode.VECTOR_SIZE_ANY, " >0 " })
56+
@IR(counts = { IRNode.STORE_VECTOR, " >0 " })
5457
private static void testDouble(double[][] a , double[][] b, double[][] c) {
5558
for(int i = 0; i < a.length; i++) {
5659
for (int j = 0; j < a[0].length; j++) {

test/hotspot/jtreg/compiler/c2/irTests/TestDisableAutoVectOpcodes.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public static void main(String[] args) {
5353
}
5454

5555
@Test
56-
@IR(failOn = {IRNode.VECTOR_CAST_D2X})
56+
@IR(failOn = {IRNode.VECTOR_CAST_D2I})
5757
private static void testConvD2I() {
5858
for(int i = 0; i < SIZE; i++) {
5959
inta[i] = (int) (doublea[i]);
6060
}
6161
}
6262

6363
@Test
64-
@IR(failOn = {IRNode.VECTOR_CAST_L2X})
64+
@IR(failOn = {IRNode.VECTOR_CAST_L2F})
6565
private static void testConvL2F() {
6666
for(int i = 0; i < SIZE; i++) {
6767
floata[i] = (float) (longa[i]);

test/hotspot/jtreg/compiler/c2/irTests/TestVectorConditionalMove.java

+127-41
Large diffs are not rendered by default.

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java

+14-15
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static private void runAndVerify3(Runnable test, int offset) {
150150
}
151151

152152
@Test
153-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
153+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
154154
public static void testByteLong1(byte[] dest, long[] src) {
155155
for (int i = 0; i < src.length; i++) {
156156
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]);
@@ -163,7 +163,7 @@ public static void testByteLong1_runner() {
163163
}
164164

165165
@Test
166-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
166+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
167167
public static void testByteLong2(byte[] dest, long[] src) {
168168
for (int i = 1; i < src.length; i++) {
169169
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]);
@@ -176,7 +176,7 @@ public static void testByteLong2_runner() {
176176
}
177177

178178
@Test
179-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
179+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
180180
public static void testByteLong3(byte[] dest, long[] src) {
181181
for (int i = 0; i < src.length - 1; i++) {
182182
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]);
@@ -189,7 +189,7 @@ public static void testByteLong3_runner() {
189189
}
190190

191191
@Test
192-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
192+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
193193
public static void testByteLong4(byte[] dest, long[] src, int start, int stop) {
194194
for (int i = start; i < stop; i++) {
195195
UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]);
@@ -203,7 +203,7 @@ public static void testByteLong4_runner() {
203203
}
204204

205205
@Test
206-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
206+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
207207
public static void testByteLong5(byte[] dest, long[] src, int start, int stop) {
208208
for (int i = start; i < stop; i++) {
209209
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]);
@@ -217,7 +217,7 @@ public static void testByteLong5_runner() {
217217
}
218218

219219
@Test
220-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
220+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
221221
public static void testByteByte1(byte[] dest, byte[] src) {
222222
for (int i = 0; i < src.length / 8; i++) {
223223
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
@@ -229,9 +229,8 @@ public static void testByteByte1_runner() {
229229
runAndVerify2(() -> testByteByte1(byteArray, byteArray), 0);
230230
}
231231

232-
// It would be legal to vectorize this one but it's not currently
233232
@Test
234-
//@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
233+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
235234
public static void testByteByte2(byte[] dest, byte[] src) {
236235
for (int i = 1; i < src.length / 8; i++) {
237236
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
@@ -244,7 +243,7 @@ public static void testByteByte2_runner() {
244243
}
245244

246245
@Test
247-
@IR(failOn = { IRNode.LOAD_VECTOR, IRNode.STORE_VECTOR })
246+
@IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
248247
public static void testByteByte3(byte[] dest, byte[] src) {
249248
for (int i = 0; i < src.length / 8 - 1; i++) {
250249
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
@@ -257,7 +256,7 @@ public static void testByteByte3_runner() {
257256
}
258257

259258
@Test
260-
@IR(failOn = { IRNode.LOAD_VECTOR, IRNode.STORE_VECTOR })
259+
@IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
261260
public static void testByteByte4(byte[] dest, byte[] src, int start, int stop) {
262261
for (int i = start; i < stop; i++) {
263262
UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
@@ -271,7 +270,7 @@ public static void testByteByte4_runner() {
271270
}
272271

273272
@Test
274-
@IR(failOn = { IRNode.LOAD_VECTOR, IRNode.STORE_VECTOR })
273+
@IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
275274
public static void testByteByte5(byte[] dest, byte[] src, int start, int stop) {
276275
for (int i = start; i < stop; i++) {
277276
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
@@ -285,7 +284,7 @@ public static void testByteByte5_runner() {
285284
}
286285

287286
@Test
288-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
287+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
289288
public static void testOffHeapLong1(long dest, long[] src) {
290289
for (int i = 0; i < src.length; i++) {
291290
UNSAFE.putLongUnaligned(null, dest + 8 * i, src[i]);
@@ -298,7 +297,7 @@ public static void testOffHeapLong1_runner() {
298297
}
299298

300299
@Test
301-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
300+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
302301
public static void testOffHeapLong2(long dest, long[] src) {
303302
for (int i = 1; i < src.length; i++) {
304303
UNSAFE.putLongUnaligned(null, dest + 8 * (i - 1), src[i]);
@@ -311,7 +310,7 @@ public static void testOffHeapLong2_runner() {
311310
}
312311

313312
@Test
314-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
313+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
315314
public static void testOffHeapLong3(long dest, long[] src) {
316315
for (int i = 0; i < src.length - 1; i++) {
317316
UNSAFE.putLongUnaligned(null, dest + 8 * (i + 1), src[i]);
@@ -324,7 +323,7 @@ public static void testOffHeapLong3_runner() {
324323
}
325324

326325
@Test
327-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
326+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
328327
public static void testOffHeapLong4(long dest, long[] src, int start, int stop) {
329328
for (int i = start; i < stop; i++) {
330329
UNSAFE.putLongUnaligned(null, dest + 8 * i + baseOffset, src[i]);

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMultiInvar.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static void main(String[] args) {
6060
static long baseOffset = 0;
6161

6262
@Test
63-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
63+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
6464
public static void testByteLong1(byte[] dest, long[] src) {
6565
for (int i = 0; i < src.length; i++) {
6666
long j = Objects.checkIndex(i * 8, (long)(src.length * 8));
@@ -75,7 +75,7 @@ public static void testByteLong1_runner() {
7575
}
7676

7777
@Test
78-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
78+
@IR(counts = { IRNode.LOAD_VECTOR_B, ">=1", IRNode.STORE_VECTOR, ">=1" })
7979
public static void testLoopNest1(byte[] dest, byte[] src,
8080
long start1, long stop1,
8181
long start2, long stop2,
@@ -106,7 +106,7 @@ public static void testLoopNest1_runner() {
106106
}
107107

108108
@Test
109-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
109+
@IR(counts = { IRNode.LOAD_VECTOR_I, ">=1", IRNode.STORE_VECTOR, ">=1" })
110110
public static void testLoopNest2(int[] dest, int[] src,
111111
long start1, long stop1,
112112
long start2, long stop2,

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationNotRun.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void main(String[] args) {
5151
static long[] longArray = new long[size];
5252

5353
@Test
54-
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
54+
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
5555
public static void test(byte[] dest, long[] src) {
5656
for (int i = 0; i < src.length; i++) {
5757
if ((i < 0) || (8 > sizeBytes - i)) {

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizeTypeConversion.java

+13-8
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public static void main(String[] args) {
5555
}
5656

5757
@Test
58-
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
59-
IRNode.VECTOR_CAST_I2X, ">0",
58+
// Mixing types of different sizes has the effect that some vectors are shorter than the type allows.
59+
@IR(counts = {IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_double)", ">0",
60+
IRNode.VECTOR_CAST_I2D, IRNode.VECTOR_SIZE + "min(max_int, max_double)", ">0",
6061
IRNode.STORE_VECTOR, ">0"},
6162
// The vectorization of some conversions may fail when `+AlignVector`.
6263
// We can remove the condition after JDK-8303827.
@@ -68,9 +69,11 @@ private static void testConvI2D(double[] d, int[] a) {
6869
}
6970

7071
@Test
71-
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
72-
IRNode.VECTOR_CAST_I2X, ">0",
73-
IRNode.VECTOR_CAST_L2X, ">0",
72+
// Mixing types of different sizes has the effect that some vectors are shorter than the type allows.
73+
@IR(counts = {IRNode.LOAD_VECTOR_L, IRNode.VECTOR_SIZE + "min(max_int, max_long)", ">0",
74+
IRNode.LOAD_VECTOR_I, IRNode.VECTOR_SIZE + "min(max_int, max_long)", ">0",
75+
IRNode.VECTOR_CAST_I2L, IRNode.VECTOR_SIZE + "min(max_int, max_long)", ">0",
76+
IRNode.VECTOR_CAST_L2I, IRNode.VECTOR_SIZE + "min(max_int, max_long)", ">0",
7477
IRNode.STORE_VECTOR, ">0"})
7578
private static void testConvI2L(int[] d1, int d2[], long[] a1, long[] a2) {
7679
for(int i = 0; i < d1.length; i++) {
@@ -80,9 +83,11 @@ private static void testConvI2L(int[] d1, int d2[], long[] a1, long[] a2) {
8083
}
8184

8285
@Test
83-
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
84-
IRNode.VECTOR_CAST_D2X, ">0",
85-
IRNode.VECTOR_CAST_F2X, ">0",
86+
// Mixing types of different sizes has the effect that some vectors are shorter than the type allows.
87+
@IR(counts = {IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
88+
IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
89+
IRNode.VECTOR_CAST_D2F, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
90+
IRNode.VECTOR_CAST_F2D, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
8691
IRNode.STORE_VECTOR, ">0"})
8792
private static void testConvF2D(double[] d1, double[] d2, float[] a1, float[] a2) {
8893
for(int i = 0; i < d1.length; i++) {

test/hotspot/jtreg/compiler/c2/irTests/TestVectorizeURShiftSubword.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,47 +70,47 @@ public static void main(String[] args) {
7070
}
7171

7272
@Test
73-
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
73+
@IR(counts = {IRNode.LOAD_VECTOR_B, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
7474
public void testByte0() {
7575
for(int i = 0; i < NUM; i++) {
7676
byteb[i] = (byte) (bytea[i] >>> 3);
7777
}
7878
}
7979

8080
@Test
81-
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
81+
@IR(counts = {IRNode.LOAD_VECTOR_B, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
8282
public void testByte1() {
8383
for(int i = 0; i < NUM; i++) {
8484
byteb[i] = (byte) (bytea[i] >>> 24);
8585
}
8686
}
8787

8888
@Test
89-
@IR(failOn = {IRNode.LOAD_VECTOR, IRNode.RSHIFT_VB, IRNode.STORE_VECTOR})
89+
@IR(failOn = {IRNode.LOAD_VECTOR_B, IRNode.RSHIFT_VB, IRNode.STORE_VECTOR})
9090
public void testByte2() {
9191
for(int i = 0; i < NUM; i++) {
9292
byteb[i] = (byte) (bytea[i] >>> 25);
9393
}
9494
}
9595

9696
@Test
97-
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
97+
@IR(counts = {IRNode.LOAD_VECTOR_S, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
9898
public void testShort0() {
9999
for(int i = 0; i < NUM; i++) {
100100
shortb[i] = (short) (shorta[i] >>> 10);
101101
}
102102
}
103103

104104
@Test
105-
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
105+
@IR(counts = {IRNode.LOAD_VECTOR_S, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
106106
public void testShort1() {
107107
for(int i = 0; i < NUM; i++) {
108108
shortb[i] = (short) (shorta[i] >>> 16);
109109
}
110110
}
111111

112112
@Test
113-
@IR(failOn = {IRNode.LOAD_VECTOR, IRNode.RSHIFT_VS, IRNode.STORE_VECTOR})
113+
@IR(failOn = {IRNode.LOAD_VECTOR_S, IRNode.RSHIFT_VS, IRNode.STORE_VECTOR})
114114
public void testShort2() {
115115
for(int i = 0; i < NUM; i++) {
116116
shortb[i] = (short) (shorta[i] >>> 17);

0 commit comments

Comments
 (0)