RFR: 8318446: C2: optimize stores into primitive arrays by combining values into larger store [v4]

Emanuel Peter epeter at openjdk.org
Mon Mar 4 13:45:49 UTC 2024


On Mon, 29 Jan 2024 12:00:32 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add diagnostic flag MergeStores
>
> Great work, Emanuel.
> 
> I think this is a well encapsulated optimization for a supposedly common code pattern requested by core libraries folks. I agree with Vladimir, that it would be nice to support this as part of the autovectorizer but that is probably not going to happen anytime soon. Until then, going with this separate phase would allow us to add support (and tests) for additional code patterns if requests come in and potentially move this to the autovectorizer later.

@TobiHartmann @vnkozlov I now check for `AryPtr`. And I think that just marking with "mismatched" must be sufficient.

Because if you do a unsafe store with a different memory size, then it is just marked as "mismatched" too. So if I now trigger bugs with this patch, then the bugs were pre-existing and could have been created using unsafe.

For example a `StoreB` on an int array: `UNSAFE.putByte(a, UNSAFE.ARRAY_INT_BASE_OFFSET + 3, (byte)0xf4);`
`74  StoreB  === 42 64 73 70  [[ 16 ]]  @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=4; mismatched unsafe  Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact[0] *, idx=4; !jvms: Test::test8 @ bci:73 (line 78)`
There is no barriers around these stores.

Of course that would be very different on fields. Fields end up on different slices, and hence you would have to be more careful there.

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

PR Comment: https://git.openjdk.org/jdk/pull/16245#issuecomment-1976611894


More information about the hotspot-compiler-dev mailing list