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 [v2]
Damon Fenacci
dfenacci at openjdk.org
Wed Jan 21 09:05:12 UTC 2026
On Mon, 19 Jan 2026 13:59:25 GMT, Roland Westrelin <roland at openjdk.org> wrote:
>> `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()`.
>
> Roland Westrelin has updated the pull request incrementally with one additional commit since the last revision:
>
> review
Marked as reviewed by dfenacci (Committer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/29231#pullrequestreview-3686064975
More information about the hotspot-compiler-dev
mailing list