[lworld] RFR: 8228361: [lworld] Optimize the substitutability check in C2 [v2]
Tobias Hartmann
thartmann at openjdk.org
Thu Dec 18 13:33:27 UTC 2025
On Thu, 18 Dec 2025 10:21:09 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
>> Tobias Hartmann has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 21 commits:
>>
>> - Merge branch 'lworld' into JDK-8228361
>> - More refactoring, better comments
>> - More comments, removing workaround
>> - Merge
>> - v5
>> - Refactoring v4
>> - Refactoring v3
>> - Refactoring, more checks, new test
>> - Merge branch 'lworld' into JDK-8228362
>> - All tests pass
>> - ... and 11 more: https://git.openjdk.org/valhalla/compare/3c41c2aa...4f8556c7
>
> src/hotspot/share/opto/inlinetypenode.cpp line 673:
>
>> 671:
>> 672: // Check if a substitutability check between 'this' and 'other' can be implemented in IR
>> 673: bool InlineTypeNode::can_emit_substitutability_check(Node* other) {
>
> Can be made `const`. Same for `check_substitutability()`.
Good catch, I'll update accordingly.
> src/hotspot/share/opto/inlinetypenode.cpp line 722:
>
>> 720: assert(base != nullptr, "lost base");
>> 721: field_ptr = igvn->register_new_node_with_optimizer(new AddPNode(base, ptr, igvn->MakeConX(field_off)));
>> 722: if (!field_is_flat(i)) {
>
> How about adding a `InlineTypeNode::field()` method and then directly calling `is_flat()`, `is_null_free()` on the field instead of reloading it each time over the index?
I think that's a good idea but out of scope of this PR because these methods are used all over the place. I filed [JDK-8374006](https://bugs.openjdk.org/browse/JDK-8374006) for this.
> src/hotspot/share/opto/subnode.cpp line 932:
>
>> 930: // CmpL(OrL(CastP2X(..), CastP2X(..)), 0L)
>> 931: // that are used by acmp to implement a "both operands are null" check.
>> 932: // See also the corresponding code in CmpPNode::Ideal.
>
> I suggest to move it above as a method comment.
But there's other code in that method that does different optimizations, right?
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1823#discussion_r2631116850
PR Review Comment: https://git.openjdk.org/valhalla/pull/1823#discussion_r2631115930
PR Review Comment: https://git.openjdk.org/valhalla/pull/1823#discussion_r2631119989
More information about the valhalla-dev
mailing list