JDK-8307137: aarch64 MacroAssembler::lookup_interface_method could use conditional compare instead of branch
Andrew Haley
aph-open at littlepinkcloud.com
Sun Apr 30 10:06:38 UTC 2023
On 4/29/23 01:18, 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.
I doubt that it'd be a win, but maybe. On out-of-order AArch64 boxes I know,
branch prediction tends to be very effective, so it won't make much difference.
Also, CCMP is error prone, being difficult to read and write. Unless
there's a significant advantage I wouldn't do it. Benchmarking might be hard
to do, though.
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
More information about the hotspot-dev
mailing list