Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

/*
* @test
* @bug 8324655 8329797 8331090
* @bug 8324655 8331090
* @key randomness
* @summary Test that if expressions are properly folded into min/max nodes
* @library /test/lib /
Expand Down Expand Up @@ -139,42 +139,6 @@ public long testMaxL2E(long a, long b) {
return a <= b ? b : a;
}

public class Dummy {
long l;
public Dummy(long l) { this.l = l; }
}

@Setup
Object[] setupDummyArray() {
Dummy[] arr = new Dummy[512];
for (int i = 0; i < 512; i++) {
arr[i] = new Dummy(RANDOM.nextLong());
}
return new Object[] { arr };
}

@Test
@Arguments(setup = "setupDummyArray")
@IR(failOn = { IRNode.MAX_L })
public long testMaxLAndBarrierInLoop(Dummy[] arr) {
long result = 0;
for (int i = 0; i < arr.length; ++i) {
result += Math.max(arr[i].l, 1);
}
return result;
}

@Test
@Arguments(setup = "setupDummyArray")
@IR(failOn = { IRNode.MIN_L })
public long testMinLAndBarrierInLoop(Dummy[] arr) {
long result = 0;
for (int i = 0; i < arr.length; ++i) {
result += Math.min(arr[i].l, 1);
}
return result;
}

@Setup
static Object[] setupIntArrays() {
int[] a = new int[512];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this should be 2025 instead even though the code was added in 2024. No strong opinion, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I was wondering that too. I guess the file is new for 2025 so I'll go with that instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the copyright to Amazon since @caojoshua added the test originally. Their copyright notice does not have year so I added it as is.

* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package compiler.c2.irTests;

import compiler.lib.ir_framework.Arguments;
import compiler.lib.ir_framework.IR;
import compiler.lib.ir_framework.IRNode;
import compiler.lib.ir_framework.Setup;
import compiler.lib.ir_framework.Test;
import compiler.lib.ir_framework.TestFramework;
import jdk.test.lib.Utils;

import java.util.Random;

/*
* @test
* @bug 8329797
* @key randomness
* @summary Test that MinL/MaxL nodes are removed when barriers in loop
* @library /test/lib /
* @run driver compiler.c2.irTests.TestMinMaxLongLoopBarrier
*/
public class TestMinMaxLongLoopBarrier {
private static final Random RANDOM = Utils.getRandomInstance();

public static void main(String[] args) {
TestFramework.run();
}

public class Dummy {
long l;
public Dummy(long l) { this.l = l; }
}

@Setup
Object[] setupDummyArray() {
Dummy[] arr = new Dummy[512];
for (int i = 0; i < 512; i++) {
arr[i] = new Dummy(RANDOM.nextLong());
}
return new Object[] { arr };
}

@Test
@Arguments(setup = "setupDummyArray")
@IR(failOn = { IRNode.MAX_L })
public long testMaxLAndBarrierInLoop(Dummy[] arr) {
long result = 0;
for (int i = 0; i < arr.length; ++i) {
result += Math.max(arr[i].l, 1);
}
return result;
}

@Test
@Arguments(setup = "setupDummyArray")
@IR(failOn = { IRNode.MIN_L })
public long testMinLAndBarrierInLoop(Dummy[] arr) {
long result = 0;
for (int i = 0; i < arr.length; ++i) {
result += Math.min(arr[i].l, 1);
}
return result;
}
}