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

8277882: New subnode ideal optimization: converting "c0 - (x + c1)" into "(c0 - c1) - x" #6441

Closed

Conversation

CptGit
Copy link
Contributor

@CptGit CptGit commented Nov 17, 2021

Suggest two new optimizations that can be done in SubINode::Ideal.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8277882: New subnode ideal optimization: converting "c0 - (x + c1)" into "(c0 - c1) - x"

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6441/head:pull/6441
$ git checkout pull/6441

Update a local copy of the PR:
$ git checkout pull/6441
$ git pull https://git.openjdk.java.net/jdk pull/6441/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6441

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6441.diff

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Nov 17, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 17, 2021

Hi @CptGit, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user CptGit" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

openjdk bot commented Nov 17, 2021

@CptGit 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 Nov 17, 2021
@CptGit
Copy link
Contributor Author

CptGit commented Nov 17, 2021

/signed

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label Nov 17, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 17, 2021

Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@merykitty
Copy link
Member

merykitty commented Nov 18, 2021

Hi,
Regarding your first transformation, x - (0 - y) is already transformed into (x + y) - 0 which is then simplified to x + y, see line 265.
Consider merging your second transformation with the one in line 243, too.
Cheers.

@merykitty
Copy link
Member

merykitty commented Nov 18, 2021

You should provide a microbenchmark to prove the effectiveness of the transformations, too.

@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Nov 24, 2021
@CptGit
Copy link
Contributor Author

CptGit commented Nov 24, 2021

@merykitty Thank you for your comments. I made the merging and included both jtreg and microbenchmark tests. Please let me know if you have any other comments.

@neliasso
Copy link

neliasso commented Nov 26, 2021

Hi @CptGit,

You need to open a enhancement-bug at https://bugs.openjdk.java.net/ for this PR.

The title of this PR must then be changed to "bug-number: bug-title" where the title matches the title of the bug.

Regards,
Nils

@CptGit CptGit closed this Nov 26, 2021
@CptGit CptGit reopened this Nov 26, 2021
@CptGit
Copy link
Contributor Author

CptGit commented Nov 26, 2021

Hi @CptGit,

You need to open a enhancement-bug at https://bugs.openjdk.java.net/ for this PR.

The title of this PR must then be changed to "bug-number: bug-title" where the title matches the title of the bug.

Regards, Nils

Thank you Nils @neliasso . I don't have an account for OpenJDK. Do you know how I can get one? I've already signed OCA and been approved.

@fmatte1
Copy link

fmatte1 commented Nov 29, 2021

Associated JBS issue - https://bugs.openjdk.java.net/browse/JDK-8277882

@CptGit CptGit changed the title hotspot compiler: add new optimizations in subnode. 8277882: New subnode ideal optimization: converting "c0 - (x + c1)" into "(c0 - c1) - x" Nov 29, 2021
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 29, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 29, 2021

src/hotspot/share/opto/subnode.cpp Outdated Show resolved Hide resolved
@dean-long
Copy link
Member

dean-long commented Nov 30, 2021

I think your tests need to check more cases, especially cases that use MIN_VALUE, MAX_VALUE, or otherwise cause underflow or overflow.

@dean-long
Copy link
Member

dean-long commented Dec 1, 2021

/reviewers 2

@openjdk
Copy link

openjdk bot commented Dec 1, 2021

@dean-long
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@merykitty
Copy link
Member

merykitty commented Dec 1, 2021

I think this could be merged with the transformation on line 216 (the one converts "x - (y+c0)" into "(x-y) - c0") and doing a branch on the constness of in1 to determine the appropriate term of in2 to do the transformation.

@dean-long
Copy link
Member

dean-long commented Dec 1, 2021

Testing results for 5965a8c look good.

@dean-long
Copy link
Member

dean-long commented Dec 2, 2021

Do you want to make the same change to SubLNode for completeness, and adds tests for "long" like you did for "int"?
If so, then you might find the refactoring that Roland is doing in 8262341 useful.

@CptGit
Copy link
Contributor Author

CptGit commented Dec 3, 2021

Added the same transformation for "long" as well as tests. Also renamed tests to more meaningful names.

@CptGit
Copy link
Contributor Author

CptGit commented Dec 3, 2021

The failure of compiler/c2/irTests/TestUnsignedComparison.java on Linux x86 was not caused by the changes in this PR and it was already fixed: #6427.

@dean-long
Copy link
Member

dean-long commented Dec 7, 2021

The latest changes still look good to me.

@veresov
Copy link
Contributor

veresov commented Dec 8, 2021

Looks like it's failing one the tests on 32-bit

@CptGit
Copy link
Contributor Author

CptGit commented Dec 8, 2021

Looks like it's failing one the tests on 32-bit

I believe the test will be passing after merging to master. Let me try to merge.

veresov
veresov approved these changes Dec 8, 2021
@openjdk
Copy link

openjdk bot commented Dec 8, 2021

⚠️ @CptGit the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout hotspot-opto-add-optimizations-for-subnode
$ git commit -c user.name='Preferred Full Name' --allow-empty -m 'Update full name'
$ git push

@openjdk
Copy link

openjdk bot commented Dec 8, 2021

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

8277882: New subnode ideal optimization: converting "c0 - (x + c1)" into "(c0 - c1) - x"

Reviewed-by: dlong, iveresov

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 1 new commit pushed to the master branch:

  • 8e8fadf: 8278428: ObjectInputStream.readFully range check incorrect

Please see this link for an up-to-date comparison between the source branch of this pull request and 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 (@dean-long, @veresov) 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 added the ready Pull request is ready to be integrated label Dec 8, 2021
@CptGit
Copy link
Contributor Author

CptGit commented Dec 8, 2021

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 8, 2021
@openjdk
Copy link

openjdk bot commented Dec 8, 2021

@CptGit
Your change (at version 395ee10) is now ready to be sponsored by a Committer.

@veresov
Copy link
Contributor

veresov commented Dec 9, 2021

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 9, 2021

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

  • 83e6a4c: 8255409: Support the new C_GetInterfaceList, C_GetInterface, and C_SessionCancel APIs in PKCS#11 v3.0
  • 3cec700: 8278463: [test] Serialization WritePrimitive test revised for readFully test fails
  • 03bf55f: 8277980: ObjectMethods::bootstrap throws NPE when lookup is null
  • 3893f4f: 8278330: dump stack trace if the jvmti test nsk/jvmti/GetThreadState/thrstat002 is failed with wrong thread state
  • b3faecf: 8276116: C2: optimize long range checks in int counted loops
  • fe2ae8e: 8276904: Optional.toString() is unnecessarily expensive
  • 6e7b7f3: 8278251: Enable "missing-explicit-ctor" check in the jdk.unsupported.desktop module
  • c83b781: 8278459: ProblemList javax/swing/JTree/4908142/bug4908142.java on macosx-aarch64
  • 8e8fadf: 8278428: ObjectInputStream.readFully range check incorrect

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Dec 9, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Dec 9, 2021
@openjdk
Copy link

openjdk bot commented Dec 9, 2021

@veresov @CptGit Pushed as commit 3524355.

💡 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
6 participants