RFR: 8328480: C2: SubTypeCheckNode in checkcast should use the klass constant of a unique concrete sub class [v2]

Roland Westrelin roland at openjdk.org
Wed Apr 3 14:36:10 UTC 2024


On Wed, 3 Apr 2024 14:24:54 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> Hm, you're right. That's the very same problem. So, a `CastPP` does not really work here. Should we go back to the previously suggested version without `CastPP`?
>> 
>>     if (improved_klass_ptr_type != klass_ptr_type) {
>>       if (improved_klass_ptr_type->singleton()) {
>>         improved_superklass = makecon(improved_klass_ptr_type);
>>       } else {
>>         superklass->raise_bottom_type(improved_klass_ptr_type);
>>         _gvn.set_type(superklass, improved_klass_ptr_type);
>>       }
>>     }
>> 
>> It's a best effort solution. We might still miss opportunities to remove sub type checks later where we could call `try_improve()` again. But at least the `SubTypeCheck` is now in sync with the `CheckCastPP` that is also only improved at parse time with `try_improve()` and not later anymore.
>> 
>> We could think about using `try_improve()` during IGVN as well to get better type information later. But I suggest to do that separately to this fix.
>
>> Should we go back to the previously suggested version without CastPP?
> 
> Isn't there a risk with that one too? if `superklass` is a `TypeNode` and its input changes to a constant for instance.

If doing this in `GraphKit` doesn't work well, maybe it should be done in `SubTypeCheckNode::Value`? This way it would apply all all stages of compilation? (That assumes we don't care of what happens if `ExpandSubTypeCheckAtParseTime` is true).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18515#discussion_r1549875327


More information about the hotspot-compiler-dev mailing list