[lworld] RFR: 8228361: [lworld] Optimize the substitutability check in C2 [v3]

Christian Hagedorn chagedorn at openjdk.org
Thu Dec 18 13:49:39 UTC 2025


On Thu, 18 Dec 2025 13:30:15 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

>> 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.

Sounds good, thanks!

>> 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?

Yes, right, keep it like that.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1823#discussion_r2631169712
PR Review Comment: https://git.openjdk.org/valhalla/pull/1823#discussion_r2631171655


More information about the valhalla-dev mailing list