RFR: 8353686: Optimize Math.cbrt for x86 64 bit platforms [v4]

Mohamed Issa duke at openjdk.org
Thu May 29 18:56:12 UTC 2025


On Thu, 29 May 2025 08:21:29 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> Mohamed Issa has updated the pull request incrementally with four additional commits since the last revision:
>> 
>>  - Remove comment mentioning invalid exception when NaN input is provided
>>  - Use rcx as base and r8 as index for address calculations in certain cbrt stub generator instructions
>>  - Remove unnecessary unpckhpd and unpcklpd definitions in macro-assembler header file
>>  - Remove unnecessary movapd definitions in macro-assembler header file
>
> src/hotspot/cpu/x86/stubGenerator_x86_64_cbrt.cpp line 185:
> 
>> 183: 
>> 184: #define __ _masm->
>> 185: 
> 
> Original Intel libm inline sequence uses hexadecimal constants, I would have preferred to use them as it is to maintain 1:1 mapping b/w instruction sequence.

The assembly reference code used for this implementation uses decimal constants.

> test/micro/org/openjdk/bench/java/lang/CbrtPerf.java line 56:
> 
>> 54:     public static class CbrtPerfRanges {
>> 55:         public static int cbrtInputCount = 2048;
>> 56: 
> 
> Please create separate CbrtPerfSpecialValues for +/- 0.0 and +/- Infinity and NaN values.
> I understand that handling special cases in intrinsic may impact general case performance but its ok to have atleast micro for it.

Ok, I added this to the new set of micro-benchmarks. I kept them as variable values.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24470#discussion_r2114551009
PR Review Comment: https://git.openjdk.org/jdk/pull/24470#discussion_r2114552717


More information about the graal-dev mailing list