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

Emanuel Peter epeter at openjdk.org
Thu Mar 7 16:05:58 UTC 2024


On Thu, 7 Mar 2024 14:55:53 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> No, they are not pushed down.
>> Consider the access on an int array:
>> `a[invar + 1]` -> `adr = base + ARRAY_INT_BASE_OFFSET + 4 * ConvI2L(invar + 1)`
>> We cannot just push the constant `1` out of the `ConvI2L`, after all `invar + 1` could overflow in the int domain ;)
>
> That's not quite right, I think. For instance, in this method:
> 
>    private static int test(int[] array, int i) {
>         return array[i + 1];
>     }
> 
> the final IR will have the  `(AddP base (AddP ...) constant)` because `ConvI2LNode::Ideal` does more than checking for overflow. The actual transformation to that final shape must be delayed until after the CastII nodes are removed though. Why that's the case is puzzling actually because `CastIINode::Ideal()` has logic to push the AddI thru the `CastII` but it's disabled for range check `CastII` nodes. I noticed this while working on 8324517. My recollection was that `ConvI2LNode::Ideal` would push thru both the `CastII` and `ConvI2L` in one go so  I wonder if it got broken at some point.

Thanks for info, I'll look into this :)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16245#discussion_r1516427023


More information about the hotspot-compiler-dev mailing list