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

Christian Hagedorn chagedorn at openjdk.org
Thu Mar 28 15:11:01 UTC 2024


On Thu, 28 Mar 2024 13:53:24 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> That's true. I've missed that we could also improve non-constants like `LoadKlass`, for example. I'm not sure if we could also have other improved types here apart from constants or `LoadKlass` (from `array_store_check()`). The only other non-constant `superklass` is passed by `LibraryCallKit::inline_Class_cast()`. From there, we either get a constant or a `CastPPNode` from which I'm not sure if it can really be improved.
>> 
>> Either way, I think we could improve the code like that to get an improved type regardless of the node, what do you think?
>> 
>> 
>>     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);
>>       }
>>     }
>
> That's what I was wondering too. Wouldn't casting `superklass` to `improved_klass_ptr_type` do all of this in a cleaner way? gvn would constant fold the result if it can.

That's even better and easier. I've pushed an update.

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

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


More information about the hotspot-compiler-dev mailing list