RFR: 8318446: C2: optimize stores into primitive arrays by combining values into larger store [v13]
Emanuel Peter
epeter at openjdk.org
Mon Mar 4 18:25:56 UTC 2024
On Mon, 4 Mar 2024 15:24:23 GMT, ExE Boss <duke at openjdk.org> wrote:
>> Emanuel Peter has updated the pull request incrementally with two additional commits since the last revision:
>>
>> - allow only array stores of same type as container
>> - mismatched access test
>
> Do we also have tests that a compiled method with merged stores like:
>
> static void storeLongLE(byte[] bytes, int offset, long value) {
> bytes[offset + 0] = (byte) (value >> 0);
> bytes[offset + 1] = (byte) (value >> 8);
> bytes[offset + 2] = (byte) (value >> 16);
> bytes[offset + 3] = (byte) (value >> 24);
> bytes[offset + 4] = (byte) (value >> 32);
> bytes[offset + 5] = (byte) (value >> 40);
> bytes[offset + 6] = (byte) (value >> 48);
> bytes[offset + 7] = (byte) (value >> 56);
> }
>
>
> still produce the correct result even when only a part of the stores fit into the array, e.g.:
>
> var arr = new byte[4];
> try {
> // storeLongLE is already C2 compiled with merged stores:
> storeLongLE(arr, 0, -1L);
>
> throw new AssertionError("Expected ArrayIndexOutOfBoundsException");
> } catch (ArrayIndexOutOfBoundsException _) {
> // ignore
> }
>
> assertTrue(
> Byte.toUnsignedInt(arr[0]) == 0xFF
> && Byte.toUnsignedInt(arr[1]) == 0xFF
> && Byte.toUnsignedInt(arr[2]) == 0xFF
> && Byte.toUnsignedInt(arr[3]) == 0xFF
> );
@ExE-Boss I am working on such a test, thanks for the suggestion!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16245#issuecomment-1977197535
More information about the hotspot-compiler-dev
mailing list