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 [v3]

Christian Hagedorn chagedorn at openjdk.org
Thu Jan 22 11:45:49 UTC 2026


On Thu, 22 Jan 2026 08:28:41 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:
> 
>   Update test/hotspot/jtreg/compiler/loopopts/TestSinkingLoadInputOfPhi.java
>   
>   Co-authored-by: Christian Hagedorn <christian.hagedorn at oracle.com>

Marked as reviewed by chagedorn (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/29231#pullrequestreview-3692040918


More information about the hotspot-compiler-dev mailing list