Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8333393: PhaseCFG::insert_anti_dependences can fail to raise LCAs and to add necessary anti-dependence edges #23691

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dlunde
Copy link
Member

@dlunde dlunde commented Feb 19, 2025

Issue Summary

When searching for load anti-dependences in GCM, the memory state for the load is sometimes represented not only by the memory node input of the load, but also other memory nodes. Because PhaseCFG::insert_anti_dependences searches for anti-dependences only from the load's memory input, it is, therefore, possible to sometimes overlook anti-dependences. The result is that loads are potentially scheduled too late, after stores that redefine the memory states of the loads.

Changeset

It is not yet clear why multiple nodes sometimes represent the memory state of a load, nor if this is expected. We can, however, resolve all the miscompiled test cases seen in this issue by improving the idealization of Phi nodes. Specifically, there is an idealization where we split Phis through input MergeMems, that we, prior to this changeset, applied too conservatively.

To illustrate the idealization and how it resolves this issue, consider the example below.

failure-graph-1

64 membar_release is a critical anti-dependence for 183 loadI. The anti-dependence search starts at the load's direct memory input, 107 Phi, and stops immediately at Phis. Therefore, the search ends at 106 Phi and we never find 64 membar_release.

We can apply the split-through-MergeMem Phi idealization to 119 Phi. This idealization pushes 119 Phi through 120 MergeMem and 121 MergeMem, splitting it into the individual inputs of the MergeMems in the process. As a result, we replace 119 Phi with two new Phis. One of these generated Phis has identical inputs to 107 Phi (106 Phi and 104 Phi), and further idealizations will merge this new Phi and 107 Phi. As a result, 107 Phi then has a Phi-free path to 64 membar_release and we correctly discover the anti-dependence.

The changeset consists of the following changes.

  • Add an analysis that allows applying the split-through-MergeMem idealization in more cases than before (including in the above example) while still ensuring termination.
  • Add a missing ResourceMark in PhiNode::split_out_instance.
  • Add multiple new regression tests in TestGCMLoadPlacement.java.

For reference, here is a previous PR with an alternative fix that we decided to discard in favor of the fix in this PR.

Testing

  • GitHub Actions
  • tier1 to tier4 (and additional Oracle-internal testing) on Windows x64, Linux x64, Linux aarch64, macOS x64, and macOS aarch64.
  • Performance testing using DaCapo, SPECjbb, and SPECjvm on Windows x64, Linux x64, Linux aarch64, macOS x64, and macOS aarch64. There are no significant improvements nor regressions.
  • C2 compilation time testing using DaCapo. There are no significant improvements nor regressions.

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-8333393: PhaseCFG::insert_anti_dependences can fail to raise LCAs and to add necessary anti-dependence edges (Bug - P3)

Contributors

  • Roberto Castañeda Lozano <rcastanedalo@openjdk.org>
  • Christian Hagedorn <chagedorn@openjdk.org>
  • Tobias Hartmann <thartmann@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23691

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 19, 2025

👋 Welcome back dlunden! 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 Feb 19, 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 8333393 8333393: PhaseCFG::insert_anti_dependences can fail to raise LCAs and to add necessary anti-dependence edges Feb 19, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 19, 2025
@openjdk
Copy link

openjdk bot commented Feb 19, 2025

@dlunde 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 Feb 19, 2025
@dlunde
Copy link
Member Author

dlunde commented Feb 19, 2025

Pinging the reviewers of the prior pull request: @chhagedorn @eme64 @robcasloz @merykitty

/contributor add rcastanedalo
/contributor add chagedorn
/contributor add thartmann

@openjdk
Copy link

openjdk bot commented Feb 19, 2025

@dlunde
Contributor Roberto Castañeda Lozano <rcastanedalo@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Feb 19, 2025

@dlunde
Contributor Christian Hagedorn <chagedorn@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Feb 19, 2025

@dlunde
Contributor Tobias Hartmann <thartmann@openjdk.org> successfully added.

@mlbridge
Copy link

mlbridge bot commented Feb 19, 2025

Webrevs

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 rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

1 participant