Skip to content

Commit 7b61bb2

Browse files
committed
Math.tanh/cbrt substitutions may not be always available
1 parent d648724 commit 7b61bb2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/StandardMethodSubstitutionsTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,21 @@ public class StandardMethodSubstitutionsTest extends MethodSubstitutionTest {
5353
public void testMathSubstitutions() {
5454
assertInGraph(assertNotInGraph(testGraph("mathAbs"), IfNode.class), AbsNode.class); // Java
5555
double value = 34567.891D;
56+
5657
testGraph("mathCos");
5758
testGraph("mathLog");
5859
testGraph("mathLog10");
5960
testGraph("mathSin");
6061
testGraph("mathSqrt");
6162
testGraph("mathTan");
62-
testGraph("mathTanh");
63-
testGraph("mathCbrt");
6463
testGraph("mathAll");
64+
if (getReplacements().hasSubstitution(getResolvedJavaMethod(Math.class, "tanh"), getInitialOptions())) {
65+
testGraph("mathTanh");
66+
}
67+
if (getReplacements().hasSubstitution(getResolvedJavaMethod(Math.class, "cbrt"), getInitialOptions())) {
68+
testGraph("mathCbrt");
69+
}
70+
testGraph("mathCbrt");
6571

6672
test("mathCos", value);
6773
test("mathLog", value);
@@ -145,7 +151,7 @@ public static double mathCbrt(double value) {
145151
}
146152

147153
public static double mathAll(double value) {
148-
return Math.sqrt(value) + Math.log(value) + Math.log10(value) + Math.sin(value) + Math.cos(value) + Math.tan(value) + Math.tanh(value) + Math.cbrt(value);
154+
return Math.sqrt(value) + Math.log(value) + Math.log10(value) + Math.sin(value) + Math.cos(value) + Math.tan(value);
149155
}
150156

151157
public void testSubstitution(String testMethodName, Class<?> holder, String methodName, boolean optional, Object[] args, Class<?>... intrinsicClasses) {

0 commit comments

Comments
 (0)