RFR: 8338694: x86_64 intrinsic for tanh using libm
Yudi Zheng
yzheng at openjdk.org
Wed Aug 28 13:17:20 UTC 2024
On Wed, 21 Aug 2024 00:25:03 GMT, Srinivas Vamsi Parasa <duke at openjdk.org> wrote:
> The goal of this PR is to implement an x86_64 intrinsic for java.lang.Math.tanh() using libm
>
> Benchmark (ops/ms) | Stock JDK | Tanh intrinsic | Speedup
> -- | -- | -- | --
> MathBench.tanhDouble | 70900 | 95618 | 1.35x
src/hotspot/share/jvmci/jvmciCompilerToVM.hpp line 114:
> 112: static address dcos;
> 113: static address dtan;
> 114: static address dtanh;
Could you please add the following initializing code?
diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
index 9752d7edf99..1db9be70db0 100644
--- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
@@ -259,6 +259,17 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
SET_TRIGFUNC(dpow);
#undef SET_TRIGFUNC
+
+#define SET_TRIGFUNC_OR_NULL(name) \
+ if (StubRoutines::name() != nullptr) { \
+ name = StubRoutines::name(); \
+ } else { \
+ name = nullptr; \
+ }
+
+ SET_TRIGFUNC_OR_NULL(dtanh);
+
+#undef SET_TRIGFUNC_OR_NULL
}
static jboolean is_c1_supported(vmIntrinsics::ID id){
diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
index fea308503cf..189c1465589 100644
--- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
+++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp
@@ -126,6 +126,7 @@
static_field(CompilerToVM::Data, dsin, address) \
static_field(CompilerToVM::Data, dcos, address) \
static_field(CompilerToVM::Data, dtan, address) \
+ static_field(CompilerToVM::Data, dtanh, address) \
static_field(CompilerToVM::Data, dexp, address) \
static_field(CompilerToVM::Data, dlog, address) \
static_field(CompilerToVM::Data, dlog10, address) \
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20657#discussion_r1734655447
More information about the core-libs-dev
mailing list