-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8357726: Improve C2 to recognize counted loops with multiple casts in trip counter #25539
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
Conversation
…le range is changed multiple times
|
👋 Welcome back xgong! A progress list of the required criteria for merging this PR into |
|
@XiaohongGong 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: 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 26 new commits pushed to the
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 |
|
@XiaohongGong The following label will be automatically applied to this pull request:
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. |
Webrevs
|
|
@XiaohongGong Nice work! @chhagedorn And I quickly discussed it offline, and we think this is a good approach. |
test/hotspot/jtreg/compiler/c2/irTests/TestCountedLoopCastIV.java
Outdated
Show resolved
Hide resolved
test/micro/org/openjdk/bench/vm/compiler/CountedLoopCastIV.java
Outdated
Show resolved
Hide resolved
|
@XiaohongGong I suggest you change the title from: |
Thanks for your suggestion! Sounds better to me. How about changing the title to |
@XiaohongGong Sounds good too :) |
|
Hi @eme64 , I'v updated the IR test and JMH based on your comments. Could you please help review whether it's fine to you. Thanks for all your suggestion! Following shows the performance data of the new JMH test on Grace (the performance gain is almost the same on my x64 machine): The error term is larger as before. But I don't think this is caused by the large variance of loop iterations. Does the new benchmark look fine to you? Thanks! |
|
@XiaohongGong Nice, thanks for the updates! Especially the IR rules and reduction in JMH benchmark variance, excellent :) Please ping me again once you have addressed my comment above, and then I can run some internal testing for you! |
chhagedorn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, too!
|
@XiaohongGong Let's please delay this until after Thursday, so that this does not go into JDK25 yet, and we have more time to fix it if something goes wrong down the line. |
Sure. That makes sense to me. Thanks! BTW, I'v updated the test according to your comment. So could you please help run all the tests? Thanks again! |
Hi @eme64 , may I ask what the status of the testing is for this PR? Any feedback please let me know. Thanks a lot! |
Change-Id: I0c10a563a3873b2220ce4d4c9b999c52159f578f
|
Ping again! |
chhagedorn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still good!
|
Let me submit some testing for it before integration. |
That's great! Thanks for your help! |
|
Testing looked good! |
eme64
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the work you put in :)
|
Thanks so much for your review @eme64 @chhagedorn @galderz ! |
|
/integrate |
|
Going to push as commit 7d6c902.
Your commit was automatically rebased without conflicts. |
|
@XiaohongGong Pushed as commit 7d6c902. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
C2 compiler fails to recognize counted loops when the induction variable is constrained by multiple consecutive
CastIInodes.This prevents optimizations like range check elimination, loop unrolling and auto-vectorization for these loops. Please refer
to the detailed discussion for a related performance issue from [1].
The ideal graph of such a loop typically looks like:
For a counted loop, the loop induction variable (i.e
Phi) should be the input ofAddIideally. However, in above case, it is usedby two consecutive
CastIInodes generated by two different range check operations. Compiler should skip all such kind ofCastIIwhen recognizing a counted loop.This patch modifies the counted loop recognition code to iteratively uncast the loop
ivuntil noCastIInodes remain, enabling proper counted loop recognition even when the induction variable undergoes multiple range constraint operations.Test:
Performance:
Here is the performance gain on a NVIDIA Grace machine which is an AArch64 architecture:
We can also observe the similar uplift on a x86_64 machine.
[1] #25138 (comment)
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25539/head:pull/25539$ git checkout pull/25539Update a local copy of the PR:
$ git checkout pull/25539$ git pull https://git.openjdk.org/jdk.git pull/25539/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25539View PR using the GUI difftool:
$ git pr show -t 25539Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25539.diff
Using Webrev
Link to Webrev Comment