Skip to content

Commit 487c477

Browse files
committed
8333647: C2 SuperWord: some additional PopulateIndex tests
Reviewed-by: kvn, chagedorn
1 parent d02cb74 commit 487c477

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
3+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
56
* This code is free software; you can redistribute it and/or modify it
@@ -46,6 +47,8 @@
4647
public class ArrayIndexFillTest extends VectorizationTestRunner {
4748

4849
private static final int SIZE = 543;
50+
private static int init = 0;
51+
private static int limit = SIZE;
4952

5053
private int[] a;
5154

@@ -101,6 +104,11 @@ public int[] fillIntArray() {
101104
}
102105

103106
@Test
107+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
108+
counts = {IRNode.POPULATE_INDEX, "=0"})
109+
// The ConvI2L can be split through the AddI, creating a mix of
110+
// ConvI2L(AddI) and AddL(ConvI2L) cases, which do not vectorize.
111+
// See: JDK-8332878
104112
public long[] fillLongArray() {
105113
long[] res = new long[SIZE];
106114
for (int i = 0; i < SIZE; i++) {
@@ -109,6 +117,65 @@ public long[] fillLongArray() {
109117
return res;
110118
}
111119

120+
@Test
121+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
122+
counts = {IRNode.POPULATE_INDEX, ">0"})
123+
// The variable init/limit has the consequence that we do not split
124+
// the ConvI2L through the AddI.
125+
public long[] fillLongArray2() {
126+
long[] res = new long[SIZE];
127+
for (int i = init; i < limit; i++) {
128+
res[i] = i;
129+
}
130+
return res;
131+
}
132+
133+
@Test
134+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
135+
counts = {IRNode.POPULATE_INDEX, "=0"})
136+
// See: JDK-8332878
137+
public float[] fillFloatArray() {
138+
float[] res = new float[SIZE];
139+
for (int i = 0; i < SIZE; i++) {
140+
res[i] = i;
141+
}
142+
return res;
143+
}
144+
145+
@Test
146+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
147+
counts = {IRNode.POPULATE_INDEX, ">0"})
148+
public float[] fillFloatArray2() {
149+
float[] res = new float[SIZE];
150+
for (int i = init; i < limit; i++) {
151+
res[i] = i;
152+
}
153+
return res;
154+
}
155+
156+
@Test
157+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
158+
counts = {IRNode.POPULATE_INDEX, "=0"})
159+
// See: JDK-8332878
160+
public double[] fillDoubleArray() {
161+
double[] res = new double[SIZE];
162+
for (int i = 0; i < SIZE; i++) {
163+
res[i] = i;
164+
}
165+
return res;
166+
}
167+
168+
@Test
169+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
170+
counts = {IRNode.POPULATE_INDEX, ">0"})
171+
public double[] fillDoubleArray2() {
172+
double[] res = new double[SIZE];
173+
for (int i = init; i < limit; i++) {
174+
res[i] = i;
175+
}
176+
return res;
177+
}
178+
112179
@Test
113180
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
114181
counts = {IRNode.POPULATE_INDEX, ">0"})

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2022, 2023, Arm Limited. All rights reserved.
3+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
56
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +51,7 @@ public class ArrayShiftOpTest extends VectorizationTestRunner {
5051

5152
private static final int SIZE = 543;
5253
private static int size = 543;
54+
private static int zero = 0;
5355

5456
private int[] ints;
5557
private long[] longs;
@@ -120,6 +122,36 @@ public long[] longCombinedRotateShift() {
120122
return res;
121123
}
122124

125+
@Test
126+
// Tests that we add a ConvI2L for size, when converting it to long for
127+
// the rotateRight rotation input.
128+
// However, it currently only seems to vectorize in OSR, so we cannot add IR rules.
129+
public long[] longExplicitRotateWithPopulateIndex() {
130+
long[] res = new long[SIZE];
131+
for (int i = 0; i < SIZE; i++) {
132+
res[i] = Long.rotateRight(i, /* some rotation value*/ size);
133+
}
134+
return res;
135+
}
136+
137+
@Test
138+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
139+
counts = {IRNode.STORE_VECTOR, ">0"})
140+
@IR(applyIfCPUFeature = {"avx512f", "true"},
141+
counts = {IRNode.ROTATE_RIGHT_V, ">0"})
142+
@IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
143+
counts = {IRNode.POPULATE_INDEX, ">0"})
144+
// The unknown init/limit values make sure that the rotation does fold badly
145+
// like in longExplicitRotateWithPopulateIndex.
146+
public long[] longExplicitRotateWithPopulateIndex2() {
147+
long[] res = new long[SIZE];
148+
for (int i = zero; i < size; i++) {
149+
res[i] = Long.rotateRight(i, /* some rotation value*/ size);
150+
}
151+
return res;
152+
}
153+
154+
123155
@Test
124156
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
125157
counts = {IRNode.RSHIFT_VI, ">0"})

0 commit comments

Comments
 (0)