Skip to content

Conversation

@eme64
Copy link
Contributor

@eme64 eme64 commented Oct 23, 2025

Analysis:
split_thru_phi can split a node out of the loop, through some loop phi. As a consequence, that node and the phi we split through can become dead. But split_thru_phi did not have any logic to yank the dead node and phi from the _body. If this happens in the same loop-opts-phase as a later SuperWord, and that SuperWord pass somehow accesses that loop _body, then we may find dead nodes, which is not expected.

It is not ok that split_thru_phi leaves dead nodes in the _body, so they have to be yanked.

What I did additionally: I went through all uses of split_thru_phi, and moved the replace_node from the call-site to the method itself. Removing the node and yanking from _body conceptually belongs together, so they should be together in code.

I suspect that split_thru_phi was broken for a long time already. But JDK26 changes in SuperWord started to check inputs of all nodes in _body, and that fails with dead nodes.

Future Work:

  • Continue work on making VerifyLoopOptimizations work again, we should assert that there are no dead nodes in the _body. We may do that with the following task, or a subsequent one.
    • JDK-8370332 Fix VerifyLoopOptimizations - step 3 - fix ctrl/loop

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8370332: C2 SuperWord: SIGSEGV because PhaseIdealLoop::split_thru_phi left dead nodes in loop _body (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27955/head:pull/27955
$ git checkout pull/27955

Update a local copy of the PR:
$ git checkout pull/27955
$ git pull https://git.openjdk.org/jdk.git pull/27955/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27955

View PR using the GUI difftool:
$ git pr show -t 27955

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27955.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 23, 2025

👋 Welcome back epeter! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 23, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title JDK-8370332 8370332: C2 SuperWord: SIGSEGV in SuperWordVTransformBuilder::build_scalar_vtnodes_for_non_packed_nodes Oct 23, 2025
@openjdk
Copy link

openjdk bot commented Oct 23, 2025

@eme64 The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@eme64 eme64 changed the title 8370332: C2 SuperWord: SIGSEGV in SuperWordVTransformBuilder::build_scalar_vtnodes_for_non_packed_nodes 8370332: C2 SuperWord: SIGSEGV because PhaseIdealLoop::split_thru_phi left dead nodes in loop _body Oct 27, 2025
@eme64 eme64 marked this pull request as ready for review October 27, 2025 11:34
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 27, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 27, 2025

Webrevs

for (uint j = 1; j < n->req(); j++) {
Node* in = n->in(j);
// Check that in is a phi, and n was its only use.
if (in->is_Phi() && in->in(0) == region &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that work if, say, we're splitting:

(Add (Phi ..) (Phi ..)

With a single Phi as input twice? Doesn't the Phi have 2 uses then (the Add, twice)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point. I'll have to see if I can find a reproducer for that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants