RFR: 8373508: C2: sinking CreateEx out of loop breaks the graph

Christian Hagedorn chagedorn at openjdk.org
Wed Dec 17 08:37:02 UTC 2025


On Tue, 16 Dec 2025 11:04:52 GMT, Roland Westrelin <roland at openjdk.org> wrote:

> A `CreateEx` gets sunk out of loop by
> `PhaseIdealLoop::try_sink_out_of_loop()` and, as a consequence, the
> following logic:
> 
> 
>   return (in(0)->is_CatchProj() && in(0)->in(0)->is_Catch() &&
>           in(0)->in(0)->in(1) == in(1)) ? this : call->in(TypeFunc::Parms);
> 
> 
> in `CreateExNode::Identity()` triggers which leads to the crash
> because `call->in(TypeFunc::Parms)` is not even an object in this
> particular case.
> 
> It's actually not clear to me what that logic in
> `CreateExNode::Identity()` is expected to do and I wonder if it's
> still needed.
> 
> Anyway, the fix I propose is to skip `CreateEx` in
> `PhaseIdealLoop::try_sink_out_of_loop()`.

That looks reasonable to me.

test/hotspot/jtreg/compiler/loopopts/TestCreateExSunkOutOfLoop.java line 30:

> 28:  * @library /test/lib
> 29:  * @run main/othervm -Xbatch ${test.main.class}
> 30:  * @run main ${test.main.class}

Since this test runs for 4s at least, I'm not sure if it's worth to have an Xbatch and non-Xbatch version. Does it trigger with both?

test/hotspot/jtreg/compiler/loopopts/TestCreateExSunkOutOfLoop.java line 73:

> 71:         Thread.sleep(Utils.adjustTimeout(4000));
> 72:     }
> 73: 

Suggestion:

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

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28842#pullrequestreview-3586539850
PR Review Comment: https://git.openjdk.org/jdk/pull/28842#discussion_r2626052301
PR Review Comment: https://git.openjdk.org/jdk/pull/28842#discussion_r2626067883


More information about the hotspot-compiler-dev mailing list