RFR: 8374725: C2: assert(x_ctrl == get_late_ctrl_with_anti_dep(x->as_Load(), early_ctrl, x_ctrl)) failed: anti-dependences were already checked

Roland Westrelin roland at openjdk.org
Wed Jan 14 13:53:59 UTC 2026


`PhaseIdealLoop::dom_lca_for_get_late_ctrl_internal()` caches
intermediate results in `_dom_lca_tags` when the late control is
computed by `PhaseIdealLoop::get_late_ctrl()` for a node `n`: the code
iterates over all uses of `n` potentially calling
`PhaseIdealLoop::dom_lca_for_get_late_ctrl_internal()` multiple
times. `_dom_lca_tags` is used to cache data that is specific to the
lca computation for `n`. `_dom_lca_tags` is set to a tag that depends
on `n` to mark the cached data as only valid during the lca
computation for `n`.

`PhaseIdealLoop::try_sink_out_of_loop()` checks that all uses of a
node are out of loop with
`PhaseIdealLoop::ctrl_of_all_uses_out_of_loop()` which also needs to
consider anti-dependences for `Load`s and also calls
`PhaseIdealLoop::dom_lca_for_get_late_ctrl_internal()` through
`PhaseIdealLoop::get_late_ctrl_with_anti_dep()`: this computes the
late control for a node and one particular out of loop
use. `_dom_lca_tags` values computed by an earlier
`PhaseIdealLoop::get_late_ctrl()` should be ignored (because it
computes the late control for a node and all its uses). To address
that issue, the tag that's used by
`PhaseIdealLoop::dom_lca_for_get_late_ctrl_internal()` is made
different on each call from
`PhaseIdealLoop::ctrl_of_all_uses_out_of_loop()` by incrementing
`_dom_lca_tags_round`.

The issue here is that one `Load` node is input to a `Phi` twice. So
the `Phi` is considered twice as a use of the node along 2 different
paths. `PhaseIdealLoop::get_late_ctrl_with_anti_dep()` is called twice
from `PhaseIdealLoop::ctrl_of_all_uses_out_of_loop()` but
`_dom_lca_tags_round` is not incremented between the 2
calls. `PhaseIdealLoop::dom_lca_for_get_late_ctrl_internal()` when
called for the second `Phi` input uses incorrect cached data which, in
turn, causes an incorrect computation.

The fix I propose is to make sure `_dom_lca_tags_round` is incremented
for every call to `PhaseIdealLoop::get_late_ctrl_with_anti_dep()`.

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

Commit messages:
 - test
 - fix

Changes: https://git.openjdk.org/jdk/pull/29231/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29231&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8374725
  Stats: 74 lines in 2 files changed: 69 ins; 5 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/29231.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29231/head:pull/29231

PR: https://git.openjdk.org/jdk/pull/29231


More information about the hotspot-compiler-dev mailing list