Skip to content

Conversation

@chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Dec 8, 2022

In IfNode::fold_compares_helper(), we merge two immediately following If nodes with a CmpI that share the left input into a single If with CmpU.

In this case here, a graph is currently dying. The If nodes are not yet removed but data was already folded in such a way that the graph currently looks like this when trying to apply IfNode::fold_compares():

image

In IfNode::is_ctrl_folds() we check if the dominating If is suited to apply this optimization. Here we check if the left inputs of the CmpI nodes are the same which is indeed the case because both CmpI have top as left input:

// Must compare same value
ctrl->in(0)->in(1)->in(1)->in(1) != NULL &&
ctrl->in(0)->in(1)->in(1)->in(1) == in(1)->in(1)->in(1);

We start merging 1641 If and 1657 If. During this process, we try to remove dead nodes that are no longer used:

if (adjusted_val->outcnt() == 0) {
igvn->remove_dead_node(adjusted_val);
}

But in this specific setup, adjusted_val is top and we try to remove it because outcnt() for top is zero. This results in the assertion failure.

The fix I propose is to not only check for equality of the left inputs in IfNode::is_ctrl_folds() but also check if one of them is top.

I was only able to reproduce this bug with a replay file and a very specific seed when using -XX:+StressIGVN.

Thanks,
Christian


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-8295116: C2: assert(dead->outcnt() == 0 && !dead->is_top()) failed: node must be dead

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11581

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 8, 2022

👋 Welcome back chagedorn! 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 openjdk bot added the rfr Pull request is ready for review label Dec 8, 2022
@openjdk
Copy link

openjdk bot commented Dec 8, 2022

@chhagedorn 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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Dec 8, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 8, 2022

Webrevs

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Looks good and trivial.

Copy link
Contributor

@robcasloz robcasloz left a comment

Choose a reason for hiding this comment

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

Nice analysis, looks good!

@openjdk
Copy link

openjdk bot commented Dec 8, 2022

@chhagedorn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8295116: C2: assert(dead->outcnt() == 0 && !dead->is_top()) failed: node must be dead

Reviewed-by: thartmann, rcastanedalo

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 18 new commits pushed to the master branch:

  • b9346e1: 8298033: Character.codePoint{At|Before}(char[], int, int) doesn't do JavaDoc-specified check
  • 297bf6a: 8287397: Print top-level exception when snippet fails to read file
  • 073897c: 8294588: Auto vectorize half precision floating point conversion APIs
  • 46cd457: 8298341: Ensure heap growth in TestNativeMemoryUsageEvents.java
  • 1166c8e: 8296896: Change virtual Thread.yield to use external submit
  • 5175965: 8298323: trivial typo in JOptionPane.OK_OPTION
  • d5cf18e: 8296198: JFileChooser throws InternalError java.lang.InternalError with Windows shortcuts
  • 74f346b: 8298075: RISC-V: Implement post-call NOPs
  • 3aa4070: 8294047: HttpResponseInputStream swallows interrupts
  • af8fb7e: 8282578: AIOOBE in javax.sound.sampled.Clip
  • ... and 8 more: https://git.openjdk.org/jdk/compare/389b8f4b788375821a8bb4b017e50f905abdad2d...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 8, 2022
@chhagedorn
Copy link
Member Author

Thanks Tobias and Roberto for the quick reviews! I'll integrate this now to get it in before the fork.

@chhagedorn
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 8, 2022

Going to push as commit 94575d1.
Since your change was applied there have been 20 commits pushed to the master branch:

  • 49b8622: 8290850: C2: create_new_if_for_predicate() does not clone pinned phi input nodes resulting in a broken graph
  • 2f426cd: 8298375: Bad copyright header in test/jdk/java/lang/Character/Supplementary.java
  • b9346e1: 8298033: Character.codePoint{At|Before}(char[], int, int) doesn't do JavaDoc-specified check
  • 297bf6a: 8287397: Print top-level exception when snippet fails to read file
  • 073897c: 8294588: Auto vectorize half precision floating point conversion APIs
  • 46cd457: 8298341: Ensure heap growth in TestNativeMemoryUsageEvents.java
  • 1166c8e: 8296896: Change virtual Thread.yield to use external submit
  • 5175965: 8298323: trivial typo in JOptionPane.OK_OPTION
  • d5cf18e: 8296198: JFileChooser throws InternalError java.lang.InternalError with Windows shortcuts
  • 74f346b: 8298075: RISC-V: Implement post-call NOPs
  • ... and 10 more: https://git.openjdk.org/jdk/compare/389b8f4b788375821a8bb4b017e50f905abdad2d...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 8, 2022
@openjdk openjdk bot closed this Dec 8, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 8, 2022
@openjdk
Copy link

openjdk bot commented Dec 8, 2022

@chhagedorn Pushed as commit 94575d1.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants