RFR: 8304016: Add BitMap find_last suite of functions

Kim Barrett kbarrett at openjdk.org
Sun Mar 19 22:09:18 UTC 2023


On Sat, 11 Mar 2023 16:46:44 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Please review this change that adds functions to BitMap for finding the last
> set/clear bit in a range.
> 
> Testing:
> mach5 tier1, including new gtesting for the new functions.

I've improved find_first/last_bit_impl since the original PR commit.

(1) In find_last_bit_impl, testing the last bit and the last word has been
improved, shaving off an instruction or two (depending on platform). The
previous version incorrectly expected shifts to set condition codes.

(2) The previous version of find_last_bit_impl expected the compiler to CSE
merge the nearly (and now actually, because of the change above) identical
code for handling found bits in cword. But gcc (at least) doen't seem to do
that, so we do it manually. This doesn't have any performance cost, just saves
20-30% of the (inline) code size.

(3) Applied to find_first_bit_impl a similar technique to (2).

The manual tail merging is a little bit indirect.  It might be that it would
be easier to understand by being explicit and using a goto.

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

PR: https://git.openjdk.org/jdk/pull/12988


More information about the hotspot-dev mailing list