[lworld] RFR: 8228361: [lworld] Optimize the substitutability check in C2 [v2]
Manuel Hässig
mhaessig at openjdk.org
Thu Dec 18 14:45:49 UTC 2025
On Thu, 18 Dec 2025 12:16:48 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
>> C2 will now remove the slow call to `ValueObjectMethods::isSubstitutable(Alt)` whenever it's able to determine the layout of one of the operands. It will then emit code to directly compare the fields.
>>
>> This patch also contains an intrinsic for `_getFieldMap` that will be used by the new core-libs implementation of the substitutability check ([JDK-8370450](https://bugs.openjdk.org/browse/JDK-8370450)) that's used by the interpreter / C1 and as a slow path in C2.
>>
>> When browsing code, I marked a few rough edges in unrelated code for follow-up cleanups with the corresponding bug numbers.
>>
>> Testing: tier1-tier6 + valhalla-comp-stress
>>
>> Thanks,
>> Tobias
>
> 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 659:
> 657: assert(is_reference_type(bt), "must be");
> 658: cmp = igvn->register_new_node_with_optimizer(new CmpPNode(val1, val2));
> 659: }
The following might be a bit cleaner and self-explanatory.
Suggestion:
if (is_single_word_type(bt)) {
if (bt == T_FLOAT) {
val1 = igvn->register_new_node_with_optimizer(new MoveF2INode(val1));
val2 = igvn->register_new_node_with_optimizer(new MoveF2INode(val2));
}
cmp = igvn->register_new_node_with_optimizer(new CmpINode(val1, val2));
} else if (is_double_word_type(bt)) {
if (bt == T_DOUBLE) {
val1 = igvn->register_new_node_with_optimizer(new MoveD2LNode(val1));
val2 = igvn->register_new_node_with_optimizer(new MoveD2LNode(val2));
}
cmp = igvn->register_new_node_with_optimizer(new CmpLNode(val1, val2));
} else {
assert(is_reference_type(bt), "must be");
cmp = igvn->register_new_node_with_optimizer(new CmpPNode(val1, val2));
}
Note, this still needs an appropriate implementation for `is_single_word_type()` in `gobal_definitions.hpp`:
```c++
inline bool is_integral_type(BasicType t) {
return is_subword_type(t) || t == T_INT || t == T_FLOAT;
}
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1823#discussion_r2631186288
More information about the valhalla-dev
mailing list