JDK-8307137: aarch64 MacroAssembler::lookup_interface_method could use conditional compare instead of branch

Boris Ulasevich boris.ulasevich at bell-sw.com
Sat Apr 29 11:40:36 UTC 2023


Peter,

I tried ccmp as part of improving itable stub on aarch64, and the 
results were not promising. Applying ccmp as suggested increased geomean 
from 15.7 ns to 15.9 ns on N1 and from 201 ns to 205 ns on A72. I don't 
think micro-architecture specialization in itable stub would bring 
universal benefits, it will only make code more complicated. I would 
appreciate your review of the AArch64 part of JDK-8305959 once I post it.

thanks,
Boris

On 4/29/2023 1:48 PM, Boris Ulasevich wrote:
> Hi Peter,
>
> Please have a look at JDK-8305959. I'm going to rewrite the itable 
> stub codes to use a single pass over itable! I have an aarch64 
> implementation which shows improvement on Ampere Altra.
>
> Boris
>
> On 4/29/2023 6:18 AM, Peter Kessler OS wrote:
>>
>> I notice that src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp 
>> MacroAssembler::lookup_interface_method loops over the itable list 
>> with code that uses two branches: one to check for a null indicating 
>> the end of the list, and one to see if the appropriate entry has been 
>> found.  aarch64 has a "ccmp" instruction that can be used to evaluate 
>> two conditions with only one branch.  On an out-of-order 
>> implementation with more integer execution units than branch units, 
>> the trading of a branch for a ccmp can be beneficial.  The downside 
>> is that one has to check, after the loop has exited, which of the 
>> conditions cause the loop to exit, but if the loop executes more than 
>> once or twice, that is still a win.
>>
>> There are other opportunities to use cmp;ccmp;br instead of 
>> cmp;br;cmp;br.  I happened to see the one in 
>> MacroAssembler::lookup_interface_method because it was in what passes 
>> for hand-written assembler in HotSpot.  For generic searches for a 
>> key in a key-value array the improvement can be ~10% on a Ampere 
>> Altra, depending on how far down the key-value array one has to look.
>>
>> I am only proposing to fix the loop in 
>> MacroAssembler::lookup_interface_method, but I would be interested in 
>> talking to people about where else the ccmp style could be applied.
>>
>> ... peter
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20230429/d303fdcc/attachment.htm>


More information about the hotspot-dev mailing list