RFR: 8369898: C2 SuperWord: assert(has_ctrl(i)) failed: should be control, not loop

Christian Hagedorn chagedorn at openjdk.org
Mon Oct 20 13:05:38 UTC 2025


On Mon, 20 Oct 2025 07:11:34 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> In `PhaseIdealLoop::create_new_if_for_multiversion`, we replace `multiversion_slow_proj` with the new `region` that merges the `new_multiversion_slow_proj` and `new_if_false`. Using `igvn.replace_node` moves all the control inputs of the outputs of the old `multiversion_slow_proj` to the new `region`. This is sufficient during IGVN, but not during loop-opts: the "controllees" of `multiversion_slow_proj` (the nodes that used to answer to `get_ctrl` with `multiversion_slow_proj`) should now be "controllees" of `region` (answer `region` for `get_ctrl`).
> 
> This is what `lazy_replace` is for:
> - It puts a "forwarding" in the `_loop_and_ctrl` table: instead of mapping `multiversion_slow_proj` to its loop, it now points to the new ctrl node `region`.
> - When we call `get_ctrl` on a "controllee" of the old `multiversion_slow_proj`, we then skip over `multiversion_slow_proj` via the "forwarding" to the new `region`.
> 
> I'm proposing a PR to improve the documentation and some renamings around `get_ctrl` and `lazy_replace`:
> https://github.com/openjdk/jdk/pull/27892
> 
> A previous PR that used `lazy_replace`, in case you want to understand more:
> https://github.com/openjdk/jdk/pull/15720

The fix looks reasonable to me and I agree that we should improve the documentation for `lazy_replace()` and also think about it's naming - by just looking at the name, one could first guess that the actual node replacement is delayed which is not the case! 

Maybe @rwestrel also wants to have a look who worked with `lazy_replace()` in the mentioned PR https://github.com/openjdk/jdk/pull/15720.

test/hotspot/jtreg/compiler/loopopts/superword/TestMultiversionSlowProjReplacementAndGetCtrl.java line 26:

> 24: /*
> 25:  * @test
> 26:  * @bug 8369902

Suggestion:

 * @bug 8369898

test/hotspot/jtreg/compiler/loopopts/superword/TestMultiversionSlowProjReplacementAndGetCtrl.java line 32:

> 30:  *          same loop-opts-phase.
> 31:  * @run main/othervm
> 32:  *      -XX:+IgnoreUnrecognizedVMOptions

Not needed:
Suggestion:

test/hotspot/jtreg/compiler/loopopts/superword/TestMultiversionSlowProjReplacementAndGetCtrl.java line 92:

> 90: 
> 91:     public static void main(String[] strArr) {
> 92:         for (int i = 0; i < 10_00; i++) {

Suggestion:

        for (int i = 0; i < 1_000; i++) {

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

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27889#pullrequestreview-3356373059
PR Review Comment: https://git.openjdk.org/jdk/pull/27889#discussion_r2444947618
PR Review Comment: https://git.openjdk.org/jdk/pull/27889#discussion_r2444944107
PR Review Comment: https://git.openjdk.org/jdk/pull/27889#discussion_r2444946780


More information about the hotspot-compiler-dev mailing list