8294198: Implement isFinite intrinsic for RISC-V
Reviewed-by: fyang, kvn
This commit is contained in:
parent
5f6ad926d7
commit
aeef3ecdc4
@ -7261,6 +7261,32 @@ instruct isInfiniteD_reg_reg(iRegINoSp dst, fRegD src)
|
|||||||
ins_pipe(fp_dop_reg_reg_d);
|
ins_pipe(fp_dop_reg_reg_d);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
// Float.isFinite
|
||||||
|
instruct isFiniteF_reg_reg(iRegINoSp dst, fRegF src)
|
||||||
|
%{
|
||||||
|
match(Set dst (IsFiniteF src));
|
||||||
|
format %{ "isFinite $dst, $src" %}
|
||||||
|
ins_encode %{
|
||||||
|
__ fclass_s(as_Register($dst$$reg), as_FloatRegister($src$$reg));
|
||||||
|
__ andi(as_Register($dst$$reg), as_Register($dst$$reg), 0b0001111110);
|
||||||
|
__ slt(as_Register($dst$$reg), zr, as_Register($dst$$reg));
|
||||||
|
%}
|
||||||
|
ins_pipe(fp_dop_reg_reg_s);
|
||||||
|
%}
|
||||||
|
|
||||||
|
// Double.isFinite
|
||||||
|
instruct isFiniteD_reg_reg(iRegINoSp dst, fRegD src)
|
||||||
|
%{
|
||||||
|
match(Set dst (IsFiniteD src));
|
||||||
|
format %{ "isFinite $dst, $src" %}
|
||||||
|
ins_encode %{
|
||||||
|
__ fclass_d(as_Register($dst$$reg), as_FloatRegister($src$$reg));
|
||||||
|
__ andi(as_Register($dst$$reg), as_Register($dst$$reg), 0b0001111110);
|
||||||
|
__ slt(as_Register($dst$$reg), zr, as_Register($dst$$reg));
|
||||||
|
%}
|
||||||
|
ins_pipe(fp_dop_reg_reg_d);
|
||||||
|
%}
|
||||||
|
|
||||||
instruct divF_reg_reg(fRegF dst, fRegF src1, fRegF src2) %{
|
instruct divF_reg_reg(fRegF dst, fRegF src1, fRegF src2) %{
|
||||||
match(Set dst (DivF src1 src2));
|
match(Set dst (DivF src1 src2));
|
||||||
|
|
||||||
|
@ -206,8 +206,11 @@ class methodHandle;
|
|||||||
do_intrinsic(_dsqrt_strict, java_lang_StrictMath, sqrt_name, double_double_signature, F_SN) \
|
do_intrinsic(_dsqrt_strict, java_lang_StrictMath, sqrt_name, double_double_signature, F_SN) \
|
||||||
\
|
\
|
||||||
do_intrinsic(_floatIsInfinite, java_lang_Float, isInfinite_name, float_bool_signature, F_S) \
|
do_intrinsic(_floatIsInfinite, java_lang_Float, isInfinite_name, float_bool_signature, F_S) \
|
||||||
do_name( isInfinite_name, "isInfinite") \
|
do_name( isInfinite_name, "isInfinite") \
|
||||||
|
do_intrinsic(_floatIsFinite, java_lang_Float, isFinite_name, float_bool_signature, F_S) \
|
||||||
|
do_name( isFinite_name, "isFinite") \
|
||||||
do_intrinsic(_doubleIsInfinite, java_lang_Double, isInfinite_name, double_bool_signature, F_S) \
|
do_intrinsic(_doubleIsInfinite, java_lang_Double, isInfinite_name, double_bool_signature, F_S) \
|
||||||
|
do_intrinsic(_doubleIsFinite, java_lang_Double, isFinite_name, double_bool_signature, F_S) \
|
||||||
\
|
\
|
||||||
do_intrinsic(_floatToRawIntBits, java_lang_Float, floatToRawIntBits_name, float_int_signature, F_SN) \
|
do_intrinsic(_floatToRawIntBits, java_lang_Float, floatToRawIntBits_name, float_int_signature, F_SN) \
|
||||||
do_name( floatToRawIntBits_name, "floatToRawIntBits") \
|
do_name( floatToRawIntBits_name, "floatToRawIntBits") \
|
||||||
|
@ -542,9 +542,15 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
|
|||||||
case vmIntrinsics::_floatIsInfinite:
|
case vmIntrinsics::_floatIsInfinite:
|
||||||
if (!Matcher::match_rule_supported(Op_IsInfiniteF)) return false;
|
if (!Matcher::match_rule_supported(Op_IsInfiniteF)) return false;
|
||||||
break;
|
break;
|
||||||
|
case vmIntrinsics::_floatIsFinite:
|
||||||
|
if (!Matcher::match_rule_supported(Op_IsFiniteF)) return false;
|
||||||
|
break;
|
||||||
case vmIntrinsics::_doubleIsInfinite:
|
case vmIntrinsics::_doubleIsInfinite:
|
||||||
if (!Matcher::match_rule_supported(Op_IsInfiniteD)) return false;
|
if (!Matcher::match_rule_supported(Op_IsInfiniteD)) return false;
|
||||||
break;
|
break;
|
||||||
|
case vmIntrinsics::_doubleIsFinite:
|
||||||
|
if (!Matcher::match_rule_supported(Op_IsFiniteD)) return false;
|
||||||
|
break;
|
||||||
case vmIntrinsics::_hashCode:
|
case vmIntrinsics::_hashCode:
|
||||||
case vmIntrinsics::_identityHashCode:
|
case vmIntrinsics::_identityHashCode:
|
||||||
case vmIntrinsics::_getClass:
|
case vmIntrinsics::_getClass:
|
||||||
|
@ -247,7 +247,9 @@ macro(MoveF2I)
|
|||||||
macro(MoveL2D)
|
macro(MoveL2D)
|
||||||
macro(MoveD2L)
|
macro(MoveD2L)
|
||||||
macro(IsInfiniteF)
|
macro(IsInfiniteF)
|
||||||
|
macro(IsFiniteF)
|
||||||
macro(IsInfiniteD)
|
macro(IsInfiniteD)
|
||||||
|
macro(IsFiniteD)
|
||||||
macro(MulD)
|
macro(MulD)
|
||||||
macro(MulF)
|
macro(MulF)
|
||||||
macro(MulHiL)
|
macro(MulHiL)
|
||||||
|
@ -307,4 +307,22 @@ class IsInfiniteDNode : public Node {
|
|||||||
virtual uint ideal_reg() const { return Op_RegI; }
|
virtual uint ideal_reg() const { return Op_RegI; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------- IsFiniteFNode -----------------------------------------------------
|
||||||
|
class IsFiniteFNode : public Node {
|
||||||
|
public:
|
||||||
|
IsFiniteFNode(Node* in1) : Node(0, in1) {}
|
||||||
|
virtual int Opcode() const;
|
||||||
|
const Type* bottom_type() const { return TypeInt::BOOL; }
|
||||||
|
virtual uint ideal_reg() const { return Op_RegI; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//---------- IsFiniteDNode -----------------------------------------------------
|
||||||
|
class IsFiniteDNode : public Node {
|
||||||
|
public:
|
||||||
|
IsFiniteDNode(Node* in1) : Node(0, in1) {}
|
||||||
|
virtual int Opcode() const;
|
||||||
|
const Type* bottom_type() const { return TypeInt::BOOL; }
|
||||||
|
virtual uint ideal_reg() const { return Op_RegI; }
|
||||||
|
};
|
||||||
|
|
||||||
#endif // SHARE_OPTO_INTRINSICNODE_HPP
|
#endif // SHARE_OPTO_INTRINSICNODE_HPP
|
||||||
|
@ -516,7 +516,9 @@ bool LibraryCallKit::try_to_inline(int predicate) {
|
|||||||
case vmIntrinsics::_doubleToLongBits:
|
case vmIntrinsics::_doubleToLongBits:
|
||||||
case vmIntrinsics::_longBitsToDouble: return inline_fp_conversions(intrinsic_id());
|
case vmIntrinsics::_longBitsToDouble: return inline_fp_conversions(intrinsic_id());
|
||||||
|
|
||||||
|
case vmIntrinsics::_floatIsFinite:
|
||||||
case vmIntrinsics::_floatIsInfinite:
|
case vmIntrinsics::_floatIsInfinite:
|
||||||
|
case vmIntrinsics::_doubleIsFinite:
|
||||||
case vmIntrinsics::_doubleIsInfinite: return inline_fp_range_check(intrinsic_id());
|
case vmIntrinsics::_doubleIsInfinite: return inline_fp_range_check(intrinsic_id());
|
||||||
|
|
||||||
case vmIntrinsics::_numberOfLeadingZeros_i:
|
case vmIntrinsics::_numberOfLeadingZeros_i:
|
||||||
@ -4537,9 +4539,15 @@ bool LibraryCallKit::inline_fp_range_check(vmIntrinsics::ID id) {
|
|||||||
case vmIntrinsics::_floatIsInfinite:
|
case vmIntrinsics::_floatIsInfinite:
|
||||||
result = new IsInfiniteFNode(arg);
|
result = new IsInfiniteFNode(arg);
|
||||||
break;
|
break;
|
||||||
|
case vmIntrinsics::_floatIsFinite:
|
||||||
|
result = new IsFiniteFNode(arg);
|
||||||
|
break;
|
||||||
case vmIntrinsics::_doubleIsInfinite:
|
case vmIntrinsics::_doubleIsInfinite:
|
||||||
result = new IsInfiniteDNode(arg);
|
result = new IsInfiniteDNode(arg);
|
||||||
break;
|
break;
|
||||||
|
case vmIntrinsics::_doubleIsFinite:
|
||||||
|
result = new IsFiniteDNode(arg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fatal_unexpected_iid(id);
|
fatal_unexpected_iid(id);
|
||||||
break;
|
break;
|
||||||
|
@ -1843,6 +1843,8 @@
|
|||||||
declare_c2_type(SignumFNode, Node) \
|
declare_c2_type(SignumFNode, Node) \
|
||||||
declare_c2_type(IsInfiniteFNode, Node) \
|
declare_c2_type(IsInfiniteFNode, Node) \
|
||||||
declare_c2_type(IsInfiniteDNode, Node) \
|
declare_c2_type(IsInfiniteDNode, Node) \
|
||||||
|
declare_c2_type(IsFiniteFNode, Node) \
|
||||||
|
declare_c2_type(IsFiniteDNode, Node) \
|
||||||
declare_c2_type(LoadVectorGatherNode, LoadVectorNode) \
|
declare_c2_type(LoadVectorGatherNode, LoadVectorNode) \
|
||||||
declare_c2_type(StoreVectorScatterNode, StoreVectorNode) \
|
declare_c2_type(StoreVectorScatterNode, StoreVectorNode) \
|
||||||
declare_c2_type(VectorLoadMaskNode, VectorNode) \
|
declare_c2_type(VectorLoadMaskNode, VectorNode) \
|
||||||
|
@ -782,6 +782,7 @@ public final class Double extends Number
|
|||||||
* floating-point value, {@code false} otherwise.
|
* floating-point value, {@code false} otherwise.
|
||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
|
@IntrinsicCandidate
|
||||||
public static boolean isFinite(double d) {
|
public static boolean isFinite(double d) {
|
||||||
return Math.abs(d) <= Double.MAX_VALUE;
|
return Math.abs(d) <= Double.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
@ -604,6 +604,7 @@ public final class Float extends Number
|
|||||||
* floating-point value, {@code false} otherwise.
|
* floating-point value, {@code false} otherwise.
|
||||||
* @since 1.8
|
* @since 1.8
|
||||||
*/
|
*/
|
||||||
|
@IntrinsicCandidate
|
||||||
public static boolean isFinite(float f) {
|
public static boolean isFinite(float f) {
|
||||||
return Math.abs(f) <= Float.MAX_VALUE;
|
return Math.abs(f) <= Float.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,7 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @summary Test intrinsics for Double methods isNaN, isFinite, isInfinite.
|
|
||||||
* @requires vm.cpu.features ~= ".*avx512dq.*" | os.arch == "riscv64"
|
|
||||||
* @library /test/lib /
|
|
||||||
* @run driver compiler.intrinsics.TestDoubleClassCheck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package compiler.intrinsics;
|
package compiler.intrinsics;
|
||||||
import compiler.lib.ir_framework.*;
|
|
||||||
import java.util.random.RandomGenerator;
|
import java.util.random.RandomGenerator;
|
||||||
import java.util.random.RandomGeneratorFactory;
|
import java.util.random.RandomGeneratorFactory;
|
||||||
|
|
||||||
@ -40,10 +31,6 @@ public class TestDoubleClassCheck {
|
|||||||
double[] inputs;
|
double[] inputs;
|
||||||
boolean[] outputs;
|
boolean[] outputs;
|
||||||
|
|
||||||
public static void main(String args[]) {
|
|
||||||
TestFramework.run(TestDoubleClassCheck.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestDoubleClassCheck() {
|
public TestDoubleClassCheck() {
|
||||||
outputs = new boolean[BUFFER_SIZE];
|
outputs = new boolean[BUFFER_SIZE];
|
||||||
inputs = new double[BUFFER_SIZE];
|
inputs = new double[BUFFER_SIZE];
|
||||||
@ -59,17 +46,6 @@ public class TestDoubleClassCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // needs to be run in (fast) debug mode
|
|
||||||
@Warmup(10000)
|
|
||||||
@IR(counts = {"IsInfiniteD", ">= 1"}) // Atleast one IsInfiniteD node is generated if intrinsic is used
|
|
||||||
public void testIsInfinite() {
|
|
||||||
for (int i = 0; i < BUFFER_SIZE; i++) {
|
|
||||||
outputs[i] = Double.isInfinite(inputs[i]);
|
|
||||||
}
|
|
||||||
checkResult("isInfinite");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void checkResult(String method) {
|
public void checkResult(String method) {
|
||||||
for (int i=0; i < BUFFER_SIZE; i++) {
|
for (int i=0; i < BUFFER_SIZE; i++) {
|
||||||
boolean expected = doubleClassCheck(inputs[i], method);
|
boolean expected = doubleClassCheck(inputs[i], method);
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022, BELLSOFT. All rights reserved.
|
||||||
|
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @summary Test intrinsic for Double.isFinite.
|
||||||
|
* @requires os.arch == "riscv64"
|
||||||
|
* @library /test/lib /
|
||||||
|
* @run driver compiler.intrinsics.TestDoubleIsFinite
|
||||||
|
*/
|
||||||
|
|
||||||
|
package compiler.intrinsics;
|
||||||
|
import compiler.lib.ir_framework.*;
|
||||||
|
|
||||||
|
public class TestDoubleIsFinite extends TestDoubleClassCheck {
|
||||||
|
public static void main(String args[]) {
|
||||||
|
TestFramework.run(TestDoubleIsFinite.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // needs to be run in (fast) debug mode
|
||||||
|
@Warmup(10000)
|
||||||
|
@IR(counts = {"IsFiniteD", ">= 1"}) // At least one IsFiniteD node is generated if intrinsic is used
|
||||||
|
public void testIsFinite() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
outputs[i] = Double.isFinite(inputs[i]);
|
||||||
|
}
|
||||||
|
checkResult("isFinite");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022, BELLSOFT. All rights reserved.
|
||||||
|
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @summary Test intrinsic for Double.isInfinite.
|
||||||
|
* @requires vm.cpu.features ~= ".*avx512dq.*" | os.arch == "riscv64"
|
||||||
|
* @library /test/lib /
|
||||||
|
* @run driver compiler.intrinsics.TestDoubleIsInfinite
|
||||||
|
*/
|
||||||
|
|
||||||
|
package compiler.intrinsics;
|
||||||
|
import compiler.lib.ir_framework.*;
|
||||||
|
|
||||||
|
public class TestDoubleIsInfinite extends TestDoubleClassCheck {
|
||||||
|
public static void main(String args[]) {
|
||||||
|
TestFramework.run(TestDoubleIsInfinite.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // needs to be run in (fast) debug mode
|
||||||
|
@Warmup(10000)
|
||||||
|
@IR(counts = {"IsInfiniteD", ">= 1"}) // At least one IsInfiniteD node is generated if intrinsic is used
|
||||||
|
public void testIsInfinite() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
outputs[i] = Double.isInfinite(inputs[i]);
|
||||||
|
}
|
||||||
|
checkResult("isInfinite");
|
||||||
|
}
|
||||||
|
}
|
@ -21,16 +21,7 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @summary Test intrinsics for Float methods isNaN, isFinite, isInfinite.
|
|
||||||
* @requires vm.cpu.features ~= ".*avx512dq.*" | os.arch == "riscv64"
|
|
||||||
* @library /test/lib /
|
|
||||||
* @run driver compiler.intrinsics.TestFloatClassCheck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package compiler.intrinsics;
|
package compiler.intrinsics;
|
||||||
import compiler.lib.ir_framework.*;
|
|
||||||
import java.util.random.RandomGenerator;
|
import java.util.random.RandomGenerator;
|
||||||
import java.util.random.RandomGeneratorFactory;
|
import java.util.random.RandomGeneratorFactory;
|
||||||
|
|
||||||
@ -40,10 +31,6 @@ public class TestFloatClassCheck {
|
|||||||
float[] inputs;
|
float[] inputs;
|
||||||
boolean[] outputs;
|
boolean[] outputs;
|
||||||
|
|
||||||
public static void main(String args[]) {
|
|
||||||
TestFramework.run(TestFloatClassCheck.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TestFloatClassCheck() {
|
public TestFloatClassCheck() {
|
||||||
outputs = new boolean[BUFFER_SIZE];
|
outputs = new boolean[BUFFER_SIZE];
|
||||||
inputs = new float[BUFFER_SIZE];
|
inputs = new float[BUFFER_SIZE];
|
||||||
@ -59,16 +46,6 @@ public class TestFloatClassCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // needs to be run in (fast) debug mode
|
|
||||||
@Warmup(10000)
|
|
||||||
@IR(counts = {"IsInfiniteF", ">= 1"}) // Atleast one IsInfiniteF node is generated if intrinsic is used
|
|
||||||
public void testIsInfinite() {
|
|
||||||
for (int i = 0; i < BUFFER_SIZE; i++) {
|
|
||||||
outputs[i] = Float.isInfinite(inputs[i]);
|
|
||||||
}
|
|
||||||
checkResult("isInfinite");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkResult(String method) {
|
public void checkResult(String method) {
|
||||||
for (int i=0; i < BUFFER_SIZE; i++) {
|
for (int i=0; i < BUFFER_SIZE; i++) {
|
||||||
boolean expected = floatClassCheck(inputs[i], method);
|
boolean expected = floatClassCheck(inputs[i], method);
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022, BELLSOFT. All rights reserved.
|
||||||
|
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @summary Test intrinsics for Float.isFinite.
|
||||||
|
* @requires os.arch == "riscv64"
|
||||||
|
* @library /test/lib /
|
||||||
|
* @run driver compiler.intrinsics.TestFloatIsFinite
|
||||||
|
*/
|
||||||
|
|
||||||
|
package compiler.intrinsics;
|
||||||
|
import compiler.lib.ir_framework.*;
|
||||||
|
|
||||||
|
public class TestFloatIsFinite extends TestFloatClassCheck {
|
||||||
|
public static void main(String args[]) {
|
||||||
|
TestFramework.run(TestFloatIsFinite.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // needs to be run in (fast) debug mode
|
||||||
|
@Warmup(10000)
|
||||||
|
@IR(counts = {"IsFiniteF", ">= 1"}) // At least one IsFiniteF node is generated if intrinsic is used
|
||||||
|
public void testIsFinite() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
outputs[i] = Float.isFinite(inputs[i]);
|
||||||
|
}
|
||||||
|
checkResult("isFinite");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022, BELLSOFT. All rights reserved.
|
||||||
|
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @summary Test intrinsics for Float.isInfinite.
|
||||||
|
* @requires vm.cpu.features ~= ".*avx512dq.*" | os.arch == "riscv64"
|
||||||
|
* @library /test/lib /
|
||||||
|
* @run driver compiler.intrinsics.TestFloatIsInfinite
|
||||||
|
*/
|
||||||
|
|
||||||
|
package compiler.intrinsics;
|
||||||
|
import compiler.lib.ir_framework.*;
|
||||||
|
|
||||||
|
public class TestFloatIsInfinite extends TestFloatClassCheck {
|
||||||
|
public static void main(String args[]) {
|
||||||
|
TestFramework.run(TestFloatIsInfinite.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test // needs to be run in (fast) debug mode
|
||||||
|
@Warmup(10000)
|
||||||
|
@IR(counts = {"IsInfiniteF", ">= 1"}) // At least one IsInfiniteF node is generated if intrinsic is used
|
||||||
|
public void testIsInfinite() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
outputs[i] = Float.isInfinite(inputs[i]);
|
||||||
|
}
|
||||||
|
checkResult("isInfinite");
|
||||||
|
}
|
||||||
|
}
|
@ -102,4 +102,29 @@ public class DoubleClassCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@OperationsPerInvocation(BUFFER_SIZE)
|
||||||
|
public void testIsFiniteStore() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
storeOutputs[i] = Double.isFinite(inputs[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@OperationsPerInvocation(BUFFER_SIZE)
|
||||||
|
public void testIsFiniteCMov() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
cmovOutputs[i] = Double.isFinite(inputs[i]) ? 9 : 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@OperationsPerInvocation(BUFFER_SIZE)
|
||||||
|
public void testIsFiniteBranch() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
cmovOutputs[i] = Double.isFinite(inputs[i]) ? call() : 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,4 +106,27 @@ public class FloatClassCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@OperationsPerInvocation(BUFFER_SIZE)
|
||||||
|
public void testIsFiniteStore() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
storeOutputs[i] = Float.isFinite(inputs[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@OperationsPerInvocation(BUFFER_SIZE)
|
||||||
|
public void testIsFiniteCMov() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
cmovOutputs[i] = Float.isFinite(inputs[i]) ? 9 : 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
@OperationsPerInvocation(BUFFER_SIZE)
|
||||||
|
public void testIsFiniteBranch() {
|
||||||
|
for (int i = 0; i < BUFFER_SIZE; i++) {
|
||||||
|
cmovOutputs[i] = Float.isFinite(inputs[i]) ? call() : 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user