Skip to content

Commit

Permalink
8329531: compiler/c2/irTests/TestIfMinMax.java fails with IRViolation…
Browse files Browse the repository at this point in the history
…Exception: There were one or multiple IR rule failures.

Reviewed-by: epeter, dfenacci
  • Loading branch information
jaskarth authored and TobiHartmann committed Apr 24, 2024
1 parent 80b381e commit 438e643
Showing 1 changed file with 49 additions and 20 deletions.
69 changes: 49 additions & 20 deletions test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

/*
* @test
* @key randomness
* @bug 8324655
* @summary Test that if expressions are properly folded into min/max nodes
* @requires os.arch != "riscv64"
Expand Down Expand Up @@ -144,9 +145,21 @@ static Object[] setupIntArrays() {
int[] a = new int[512];
int[] b = new int[512];

for (int i = 0; i < 512; i++) {
// Fill from 1 to 50
for (int i = 0; i < 50; i++) {
a[i] = i + 1;
b[i] = 1;
}

// Fill from -1 to -50
for (int i = 50; i < 100; i++) {
a[i] = -(i - 49);
b[i] = 1;
}

for (int i = 100; i < 512; i++) {
a[i] = RANDOM.nextInt();
b[i] = RANDOM.nextInt();
b[i] = 1;
}

return new Object[] { a, b };
Expand All @@ -157,9 +170,21 @@ static Object[] setupLongArrays() {
long[] a = new long[512];
long[] b = new long[512];

for (int i = 0; i < 512; i++) {
// Fill from 1 to 50
for (int i = 0; i < 50; i++) {
a[i] = i + 1;
b[i] = 1;
}

// Fill from -1 to -50
for (int i = 50; i < 100; i++) {
a[i] = -(i - 49);
b[i] = 1;
}

for (int i = 100; i < 512; i++) {
a[i] = RANDOM.nextLong();
b[i] = RANDOM.nextLong();
b[i] = 1;
}

return new Object[] { a, b };
Expand All @@ -173,22 +198,23 @@ static Object[] setupLongArrays() {
public Object[] testMaxIntReduction(int[] a, int[] b) {
int r = 0;
for (int i = 0; i < a.length; i++) {
int aI = a[i] * 2;
int aI = a[i] * b[i];

r = aI > r ? aI : r;
}

return new Object[] { a, r };
return new Object[] { a, b, r };
}

@Check(test = "testMaxIntReduction")
public void checkTestMaxIntReduction(Object[] vals) {
int[] a = (int[]) vals[0];
int testRet = (int) vals[1];
int[] b = (int[]) vals[1];
int testRet = (int) vals[2];

int r = 0;
for (int i = 0; i < a.length; i++) {
int aI = a[i] * 2;
int aI = a[i] * b[i];

r = aI > r ? aI : r;
}
Expand All @@ -207,22 +233,23 @@ public Object[] testMinIntReduction(int[] a, int[] b) {
int r = 0;

for (int i = 0; i < a.length; i++) {
int aI = a[i] * 2;
int aI = a[i] * b[i];

r = aI < r ? aI : r;
}

return new Object[] { a, r };
return new Object[] { a, b, r };
}

@Check(test = "testMinIntReduction")
public void checkTestMinIntReduction(Object[] vals) {
int[] a = (int[]) vals[0];
int testRet = (int) vals[1];
int[] b = (int[]) vals[1];
int testRet = (int) vals[2];

int r = 0;
for (int i = 0; i < a.length; i++) {
int aI = a[i] * 2;
int aI = a[i] * b[i];

r = aI < r ? aI : r;
}
Expand All @@ -241,22 +268,23 @@ public Object[] testMaxLongReduction(long[] a, long[] b) {
long r = 0;

for (int i = 0; i < a.length; i++) {
long aI = a[i] * 2;
long aI = a[i] * b[i];

r = aI > r ? aI : r;
}

return new Object[] { a, r };
return new Object[] { a, b, r };
}

@Check(test = "testMaxLongReduction")
public void checkTestMaxLongReduction(Object[] vals) {
long[] a = (long[]) vals[0];
long testRet = (long) vals[1];
long[] b = (long[]) vals[1];
long testRet = (long) vals[2];

long r = 0;
for (int i = 0; i < a.length; i++) {
long aI = a[i] * 2;
long aI = a[i] * b[i];

r = aI > r ? aI : r;
}
Expand All @@ -275,22 +303,23 @@ public Object[] testMinLongReduction(long[] a, long[] b) {
long r = 0;

for (int i = 0; i < a.length; i++) {
long aI = a[i] * 2;
long aI = a[i] * b[i];

r = aI < r ? aI : r;
}

return new Object[] { a, r };
return new Object[] { a, b, r };
}

@Check(test = "testMinLongReduction")
public void checkTestMinLongReduction(Object[] vals) {
long[] a = (long[]) vals[0];
long testRet = (long) vals[1];
long[] b = (long[]) vals[1];
long testRet = (long) vals[2];

long r = 0;
for (int i = 0; i < a.length; i++) {
long aI = a[i] * 2;
long aI = a[i] * b[i];

r = aI < r ? aI : r;
}
Expand Down

1 comment on commit 438e643

@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.