RFR: 8282365: Optimize divideUnsigned and remainderUnsigned for constants [v4]
Quan Anh Mai
qamai at openjdk.org
Tue Sep 27 19:12:45 UTC 2022
On Tue, 20 Sep 2022 00:24:57 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
>> Quan Anh Mai has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 20 commits:
>>
>> - code styles
>> - Merge branch 'master' into unsignedDiv
>> - Merge branch 'master' into unsignedDiv
>> - Merge branch 'master' into unsignedDiv
>> - micro
>> - whitespace
>> - whitespace
>> - large divisor
>> - fix build
>> - fix 32-bit
>> - ... and 10 more: https://git.openjdk.org/jdk/compare/3419363e...156f65c0
>
> src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 5468:
>
>> 5466: // Fastpath for divisor < 0:
>> 5467: // quotient = (dividend & ~(dividend - divisor)) >>> (Integer.SIZE - 1)
>> 5468: // See Hacker's Delight (2nd ed), section 9.3 which is implemented in java.lang.Long.divideUnsigned()
>
> Where is ideal implementation of this optimization (you changed `.ad` to handle only positive cases)?
> I see you mixed positive and negative divisor values in JMH tests. Can you do separately?
An ideal rule is added to transform the division if the divisor is known to be negative, I don't think a runtime branch is beneficial, and users of the method can always do it from Java if the data is expected to have a significant rate of negative divisor. WDYT?
-------------
PR: https://git.openjdk.org/jdk/pull/9947
More information about the hotspot-compiler-dev
mailing list