On Tue, 13 Jan 2026 10:13:23 GMT, Marc Chevalier <[email protected]> wrote:
> Before [JDK-8372634](https://bugs.openjdk.org/browse/JDK-8372634) in > `Parse::sharpen_type_after_if`, we had > https://github.com/openjdk/valhalla/blob/4e9525ef3619b02e905f16b89261b82c70830f3a/src/hotspot/share/opto/parse2.cpp#L1727-L1733 > where `static Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n)` can > fail > https://github.com/openjdk/valhalla/blob/4e9525ef3619b02e905f16b89261b82c70830f3a/src/hotspot/share/opto/parse2.cpp#L1695-L1708 > if `val` is not a `LoadKlass` (or narrow version of it). In this case, `obj` > would be `nullptr` and then nothing is done. > > Now, we have > https://github.com/openjdk/valhalla/blob/f2e56e4c18080616e8ef275a3d9c1da824efda26/src/hotspot/share/opto/parse2.cpp#L1805-L1807 > that can take this branch > https://github.com/openjdk/valhalla/blob/f2e56e4c18080616e8ef275a3d9c1da824efda26/src/hotspot/share/opto/parse2.cpp#L1734-L1741 > where `extract_obj_from_klass_load` is unchanged, and can still fail. Yet, we > have an `assert` now. That seems slightly fishy, but except in the case at > hand, it doesn't mean to fire, so... it might be ok? Otherwise, replacing the > return with `return (*obj) != nullptr;` would work. > > But in the case we have, there isn't a `Bool(CmpP(LoadKlass(obj._klass), > ConP(Foo.klass)), [eq])` as written in the comment, but instead a > > Bool(FlatArrayCheck(Proj[mem](...), ConP), [eq]) > > This happens because `FlatArrayCheckNode` is a derived class from `CmpNode`. > Yet, it doesn't work like a normal compare node: it's not necessarily binary, > but mostly, having a constant operand doesn't allow to refine the other. So I > suggest we don't even try `sharpen_type_after_if` in this case. > > > Thanks, > Marc Looks good to me too. ------------- Marked as reviewed by thartmann (Committer). PR Review: https://git.openjdk.org/valhalla/pull/1893#pullrequestreview-3655147421
