Skip to content

Commit

Permalink
8310308: IR Framework: check for type and size of vector nodes
Browse files Browse the repository at this point in the history
8314513: [IR Framework] Some internal IR Framework tests are failing after JDK-8310308 on PPC and Cascade Lake

Reviewed-by: mbaesken
Backport-of: a02d65efccaab5bb7c2f2aad4a2eb5062f545ef8
  • Loading branch information
GoeLin committed Dec 22, 2023
1 parent 506c4de commit 6b938b8
Show file tree
Hide file tree
Showing 70 changed files with 3,491 additions and 2,067 deletions.
8 changes: 4 additions & 4 deletions test/hotspot/jtreg/compiler/c2/TestMinMaxSubword.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class TestMinMaxSubword {
// as Java APIs for Math.min/max do not support integer subword types and superword
// should not generate vectorized Min/Max nodes for them.
@Test
@IR(failOn = {IRNode.MIN_V})
@IR(failOn = {IRNode.MIN_VI, IRNode.MIN_VF, IRNode.MIN_VD})
public static void testMinShort() {
for (int i = 0; i < LENGTH; i++) {
sb[i] = (short) Math.min(sa[i], val);
Expand All @@ -77,7 +77,7 @@ public static void testMinShort_runner() {
}

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

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

@Test
@IR(failOn = {IRNode.MAX_V})
@IR(failOn = {IRNode.MAX_VI, IRNode.MAX_VF, IRNode.MAX_VD})
public static void testMaxByte() {
for (int i = 0; i < LENGTH; i++) {
bb[i] = (byte) Math.max(ba[i], val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void main(String[] args) {


@Test
@IR(counts = {IRNode.LOAD_VECTOR, " >0 "})
@IR(counts = {IRNode.LOAD_VECTOR_I, " >0 "})
@IR(counts = {IRNode.STORE_VECTOR, " >0 "})
private static void testCountingDown(int[] a, int[] b) {
for (int i = 2000; i > 0; i--) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ public static void main(String[] args) {
}

@Test
@IR(counts = { IRNode.LOAD_VECTOR, " >0 " })
@IR(counts = { IRNode.ADD_VD, " >0 " })
@IR(counts = { IRNode.STORE_VECTOR, " >0 " })
// Given small iteration count, the unrolling factor is not very predictable,
// hence it is difficult to exactly predict the vector size. But let's at least
// check that there is some vectorization of any size.
@IR(counts = { IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE_ANY, " >0 " })
@IR(counts = { IRNode.ADD_VD, IRNode.VECTOR_SIZE_ANY, " >0 " })
@IR(counts = { IRNode.STORE_VECTOR, " >0 " })
private static void testDouble(double[][] a , double[][] b, double[][] c) {
for(int i = 0; i < a.length; i++) {
for (int j = 0; j < a[0].length; j++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public static void main(String[] args) {
}

@Test
@IR(failOn = {IRNode.VECTOR_CAST_D2X})
@IR(failOn = {IRNode.VECTOR_CAST_D2I})
private static void testConvD2I() {
for(int i = 0; i < SIZE; i++) {
inta[i] = (int) (doublea[i]);
}
}

@Test
@IR(failOn = {IRNode.VECTOR_CAST_L2X})
@IR(failOn = {IRNode.VECTOR_CAST_L2F})
private static void testConvL2F() {
for(int i = 0; i < SIZE; i++) {
floata[i] = (float) (longa[i]);
Expand Down
168 changes: 127 additions & 41 deletions test/hotspot/jtreg/compiler/c2/irTests/TestVectorConditionalMove.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static private void runAndVerify3(Runnable test, int offset) {
}

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

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

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

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

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

@Test
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
public static void testByteByte1(byte[] dest, byte[] src) {
for (int i = 0; i < src.length / 8; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
Expand All @@ -231,7 +231,7 @@ public static void testByteByte1_runner() {

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

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

@Test
@IR(failOn = { IRNode.LOAD_VECTOR, IRNode.STORE_VECTOR })
@IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
public static void testByteByte4(byte[] dest, byte[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
Expand All @@ -271,7 +271,7 @@ public static void testByteByte4_runner() {
}

@Test
@IR(failOn = { IRNode.LOAD_VECTOR, IRNode.STORE_VECTOR })
@IR(failOn = { IRNode.LOAD_VECTOR_L, IRNode.STORE_VECTOR })
public static void testByteByte5(byte[] dest, byte[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), UNSAFE.getLongUnaligned(src, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i));
Expand All @@ -285,7 +285,7 @@ public static void testByteByte5_runner() {
}

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

@Test
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
public static void testOffHeapLong2(long dest, long[] src) {
for (int i = 1; i < src.length; i++) {
UNSAFE.putLongUnaligned(null, dest + 8 * (i - 1), src[i]);
Expand All @@ -311,7 +311,7 @@ public static void testOffHeapLong2_runner() {
}

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

@Test
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
public static void testOffHeapLong4(long dest, long[] src, int start, int stop) {
for (int i = start; i < stop; i++) {
UNSAFE.putLongUnaligned(null, dest + 8 * i + baseOffset, src[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void main(String[] args) {
static long baseOffset = 0;

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

@Test
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
@IR(counts = { IRNode.LOAD_VECTOR_B, ">=1", IRNode.STORE_VECTOR, ">=1" })
public static void testLoopNest1(byte[] dest, byte[] src,
long start1, long stop1,
long start2, long stop2,
Expand Down Expand Up @@ -106,7 +106,7 @@ public static void testLoopNest1_runner() {
}

@Test
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
@IR(counts = { IRNode.LOAD_VECTOR_I, ">=1", IRNode.STORE_VECTOR, ">=1" })
public static void testLoopNest2(int[] dest, int[] src,
long start1, long stop1,
long start2, long stop2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void main(String[] args) {
static long[] longArray = new long[size];

@Test
@IR(counts = { IRNode.LOAD_VECTOR, ">=1", IRNode.STORE_VECTOR, ">=1" })
@IR(counts = { IRNode.LOAD_VECTOR_L, ">=1", IRNode.STORE_VECTOR, ">=1" })
public static void test(byte[] dest, long[] src) {
for (int i = 0; i < src.length; i++) {
if ((i < 0) || (8 > sizeBytes - i)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public static void main(String[] args) {
}

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

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

@Test
@IR(counts = {IRNode.LOAD_VECTOR, ">0",
IRNode.VECTOR_CAST_D2X, ">0",
IRNode.VECTOR_CAST_F2X, ">0",
// Mixing types of different sizes has the effect that some vectors are shorter than the type allows.
@IR(counts = {IRNode.LOAD_VECTOR_F, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
IRNode.LOAD_VECTOR_D, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
IRNode.VECTOR_CAST_D2F, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
IRNode.VECTOR_CAST_F2D, IRNode.VECTOR_SIZE + "min(max_float, max_double)", ">0",
IRNode.STORE_VECTOR, ">0"})
private static void testConvF2D(double[] d1, double[] d2, float[] a1, float[] a2) {
for(int i = 0; i < d1.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,47 +70,47 @@ public static void main(String[] args) {
}

@Test
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
@IR(counts = {IRNode.LOAD_VECTOR_B, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
public void testByte0() {
for(int i = 0; i < NUM; i++) {
byteb[i] = (byte) (bytea[i] >>> 3);
}
}

@Test
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
@IR(counts = {IRNode.LOAD_VECTOR_B, ">0", IRNode.RSHIFT_VB, ">0", IRNode.STORE_VECTOR, ">0"})
public void testByte1() {
for(int i = 0; i < NUM; i++) {
byteb[i] = (byte) (bytea[i] >>> 24);
}
}

@Test
@IR(failOn = {IRNode.LOAD_VECTOR, IRNode.RSHIFT_VB, IRNode.STORE_VECTOR})
@IR(failOn = {IRNode.LOAD_VECTOR_B, IRNode.RSHIFT_VB, IRNode.STORE_VECTOR})
public void testByte2() {
for(int i = 0; i < NUM; i++) {
byteb[i] = (byte) (bytea[i] >>> 25);
}
}

@Test
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
@IR(counts = {IRNode.LOAD_VECTOR_S, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
public void testShort0() {
for(int i = 0; i < NUM; i++) {
shortb[i] = (short) (shorta[i] >>> 10);
}
}

@Test
@IR(counts = {IRNode.LOAD_VECTOR, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
@IR(counts = {IRNode.LOAD_VECTOR_S, ">0", IRNode.RSHIFT_VS, ">0", IRNode.STORE_VECTOR, ">0"})
public void testShort1() {
for(int i = 0; i < NUM; i++) {
shortb[i] = (short) (shorta[i] >>> 16);
}
}

@Test
@IR(failOn = {IRNode.LOAD_VECTOR, IRNode.RSHIFT_VS, IRNode.STORE_VECTOR})
@IR(failOn = {IRNode.LOAD_VECTOR_S, IRNode.RSHIFT_VS, IRNode.STORE_VECTOR})
public void testShort2() {
for(int i = 0; i < NUM; i++) {
shortb[i] = (short) (shorta[i] >>> 17);
Expand Down
Loading

1 comment on commit 6b938b8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.