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

Peter Kessler OS peter.kessler at os.amperecomputing.com
Sat Apr 29 00:18:58 UTC 2023


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/5dd41663/attachment-0001.htm>


More information about the hotspot-dev mailing list