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

Christian Hagedorn chagedorn at openjdk.org
Wed Apr 3 14:18:08 UTC 2024


On Thu, 28 Mar 2024 16:43:49 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> Ok. Makes sense. Thanks for the explanation.
>
> Then isn't there a risk that after some transformation the `CastPP` ends up with an input that's a constant superklass which would cause the `CastPP` to transform to top?

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.

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

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


More information about the hotspot-compiler-dev mailing list