RFR: 8372634: C2: Materialize type information from instanceof checks [v6]
Vladimir Ivanov
vlivanov at openjdk.org
Wed Dec 10 21:27:24 UTC 2025
On Sat, 6 Dec 2025 01:12:53 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
>> There are multiple ways without having to have yet another higher-level representation. The first one is that since `SubTypeCheck` does not accept `null` now, we can just choose one result for `null`. Choosing the `instanceof` approach may be a little more desirable, as it removes the need to perform this complicated match, and for `checkcast` we can manually insert a `CheckCastPP` anyway. Another solution is to have another input to `SubTypeCheck` which gives the result when the `obj` is `null`. On a whim, I kind of like this, as we can match both the `checkcast` and the `instanceof` pattern here, it also simplifies `GraphKit::gen_checkcast`, as we do not have to worry about "the cast that always succeeds will leave behind a null check".
>>
>> Just a suggestion, though. This PR is fine as it is to me.
>
> I agree it can be implemented without introducing new fancy IR nodes. The open question to me though is whether we can live without materializing null check until `SubTypeCheck` nodes are macro expanded. Otherwise, it'll turn into a gradual lowering through different representations.
BTW null checks which have to be merged back break the matching of the IR shape. Something to improve as a follow-up change. Added new test cases to track it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28517#discussion_r2608248637
More information about the hotspot-compiler-dev
mailing list