RFR: 8334647: C2: CastII added by PhaseIdealLoop::add_template_assertion_predicate() should have control

Christian Hagedorn chagedorn at openjdk.org
Fri Jun 21 08:52:09 UTC 2024


On Thu, 20 Jun 2024 14:51:08 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> `PhaseIdealLoop::add_template_assertion_predicate()` creates a new
> `CastII` but doesn't set its control. I think it's good practice to
> always set the control of a `CastII` when it narrows the type of its
> input (it has to be control dependent on some condition that makes the
> narrowing possible). This is also motivated by
> https://bugs.openjdk.org/browse/JDK-8275202 where a node that becomes
> top is used as an indication that control flow where the node changes
> type can constant fold. This only works if control is set correctly.

IIUC, the rational behind it is that when a `CastII` becomes top, then some control path must also be folded to not end up with a broken graph. And the control path to be folded should be the one on which the `CastII` is control dependent on with a control input?

Are there other places where a `CastII` is currently without control input? If so, should we fix those as well?

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

PR Comment: https://git.openjdk.org/jdk/pull/19808#issuecomment-2182306789


More information about the hotspot-compiler-dev mailing list