RFR: 8345485: C2 MergeLoads: merge adjacent array/native memory loads into larger load [v4]

Emanuel Peter epeter at openjdk.org
Tue Mar 18 09:49:09 UTC 2025


On Tue, 18 Mar 2025 09:14:48 GMT, kuaiwei <duke at openjdk.org> wrote:

>> src/hotspot/share/opto/memnode.cpp line 1896:
>> 
>>> 1894:     LowToHigh,          // Adjacent and first load access low address
>>> 1895:     HighToLow,          // Adjacent and first load access high address
>>> 1896:     NotAdjacent         // Not adjacent
>> 
>> What happens if an `OrNode` has its inputs swapped? This can happen if the node idx are the "wrong way around". See `commute`, comment `Otherwise, sort inputs (commutativity) to help value numbering`.
>> 
>> I don't know how likely this is to happen. What do you think?
>
> I think it's ok to swap. I collected merged mem info and sorted them by shift value. Then check the memory order. So if shift order follows memory access order (or reverse), they can be merged.

Ah nice! That means you could add some tests where the order is shuffled, right?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24023#discussion_r2000611346


More information about the hotspot-compiler-dev mailing list