RFR: 8349479: C2: when a Type node becomes dead, make CFG path that uses it unreachable [v7]

Christian Hagedorn chagedorn at openjdk.org
Mon Apr 7 06:54:55 UTC 2025


On Thu, 3 Apr 2025 14:09:58 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> src/hotspot/share/opto/phaseX.cpp line 1836:
>> 
>>> 1834:       _type_nodes.push(n);
>>> 1835:     }
>>> 1836:     const Type* new_type = n->Value(this);
>> 
>> Could we also only add `n` to `_type_nodes` if `new_type` is top? Then we could also rename `_type_nodes` to `_maybe_top_type_nodes` or something like that.
>
> if `new_type` is top?
> As node's types are widen by CCP, a node `n` will initially be `top`, then one input changes and becomes not `top` but if the node has another input (say control), that other input will still be `top` so the type will be `top` again. Only once both inputs are not `top` is the type not `top`. So isn't there a good chance that most type nodes will initially be `top` and be enqueued anyway so filtering nodes when they are popped is still required and we don't gain much by doing what you suggest?

That's true, for most nodes it probably does not matter. But I'm thinking about `Phi` nodes which could already be updated when one path is non-top. So, it might still be worth to do it after `Value()` only? IIUC, it does not matter from a correctness point of view if enqueue before or after `Value()` - we would still filter later for `top` either way.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23468#discussion_r2030562198


More information about the hotspot-compiler-dev mailing list