Skip to content

8359603: Missed optimization in PhaseIterGVN for redundant ConvX2Y->ConvY2X->ConvX2Y sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist #26368

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

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

Conversation

benoitmaillard
Copy link
Contributor

@benoitmaillard benoitmaillard commented Jul 17, 2025

This PR addresses a missed optimization in PhaseIterGVN due to the lack of change notification to indirect users within PhaseIterGVN::add_users_of_use_to_worklist (again). This is similar to JDK-8361700.

The optimization in question is the removal of redundant ConvX2Y->ConvY2X->ConvX2Y sequences (where X and Y are primitive number types), which get replaced by a single ConvX2Y as an identity optimization. This missing optimization was originally reported only for ConvD2LNode, but it turns out that other conversion nodes have analog optimization patterns. After manual inspection of identity optimizations in convertnode.cpp, I was able to reproduce missing optimizations for the following conversion sequences:

  • ConvD2L->ConvL2D->ConvD2L
  • ConvF2I->ConvI2F->ConvF2I
  • ConvF2L->ConvL2F->ConvF2L
  • ConvI2F->ConvF2I->ConvI2F

Similar optimization patterns exist for additional conversion nodes. However, it is not clear if these nodes are subject to the same missed optimization issue. Further investigation may be needed, as I was unable to reproduce such cases with simple tests.

This is again a case where an optimization depends on the input of its input. Currently, PhaseIterGVN::add_users_of_use_to_worklist contains specific logic to handle similar dependencies for other cases, but this specific scenario is not addressed. The proposed fix adds the necessary logic in add_users_of_use_to_worklist to ensure proper notification for this optimization pattern.

Testing

  • GitHub Actions
  • tier1-3, plus some internal testing
  • Added test from the fuzzer, and tests for other sequences (manually derived from the original one)

Thank you for reviewing!


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-8359603: Missed optimization in PhaseIterGVN for redundant ConvX2Y->ConvY2X->ConvX2Y sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26368

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 17, 2025

👋 Welcome back bmaillard! 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 Jul 17, 2025

@benoitmaillard 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:

8359603: Missed optimization in PhaseIterGVN for redundant ConvX2Y->ConvY2X->ConvX2Y sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist

Reviewed-by: chagedorn

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 35 new commits pushed to the master branch:

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@chhagedorn) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot changed the title 8359603 8359603: Missed optimization in PhaseIterGVN for redundant ConvD2L->ConvL2D->ConvD2L sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist Jul 17, 2025
@openjdk
Copy link

openjdk bot commented Jul 17, 2025

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

@benoitmaillard benoitmaillard changed the title 8359603: Missed optimization in PhaseIterGVN for redundant ConvD2L->ConvL2D->ConvD2L sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist 8359603: Missed optimization in PhaseIterGVN for redundant ConvX2Y->ConvY2X->ConvX2Y sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist Jul 18, 2025
@openjdk
Copy link

openjdk bot commented Jul 21, 2025

@benoitmaillard this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8359603
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Jul 21, 2025
@benoitmaillard benoitmaillard marked this pull request as ready for review July 21, 2025 08:13
@openjdk openjdk bot added rfr Pull request is ready for review and removed merge-conflict Pull request has merge conflict with target branch labels Jul 21, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 21, 2025

Webrevs

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Two minor comments, otherwise, it looks good to me!

* @summary Redundant ConvX2Y->ConvY2X->ConvX2Y sequences should be
* simplified to a single ConvX2Y operation when applicable
* VerifyIterativeGVN checks that this optimization was applied
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=quiet
Copy link
Member

Choose a reason for hiding this comment

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

I think you can remove quiet:

Suggested change
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompileCommand=quiet
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions

}

public static void main(String[] strArr) {
for (int i = 0; i < 50_000; ++i) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need 50000 iterations each? Would less also trigger the bug?

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 23, 2025
Comment on lines +2562 to +2565
// ConvD2L->ConvL2D->ConvD2L
// ConvF2I->ConvI2F->ConvF2I
// ConvF2L->ConvL2F->ConvF2L
// ConvI2F->ConvF2I->ConvI2F
Copy link
Member

Choose a reason for hiding this comment

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

Another thought: Since this is an incomplete list of variations (especially missing, for example, the I2D version while the I2F version is here), should we leave a comment about not being able to trigger issues with the other versions? Otherwise, it could suggest that it was just forgotten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants