RFR: 8338694: x86_64 intrinsic for tanh using libm

Andrew Haley aph at openjdk.org
Tue Aug 27 10:57:08 UTC 2024


On Tue, 27 Aug 2024 05:24:34 GMT, Jatin Bhateja <jbhateja 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/cpu/x86/stubGenerator_x86_64_tanh.cpp line 437:
> 
>> 435:   __ mulpd(xmm1, xmm1);
>> 436:   __ movdqu(xmm4, ExternalAddress(pv + 32), r11 /*rscratch*/);
>> 437:   __ mulpd(xmm2, xmm1);
> 
> I would encourage either you add detailed comments or give meaningful names to the registers to ease the review process.

I agree, this is all rather obscure. Ideally the same names that are used in wherever this comes from.

Where does the algorithm come from? What are its accuracy guarantees?

In addition, given the rarity of hyperbolic tangents in Java applications, do we need this?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20657#discussion_r1732613573


More information about the core-libs-dev mailing list