-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8361140: Missing OptimizePtrCompare check in ConnectionGraph::reduce_phi_on_cmp #26125
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
…phi_on_cmp When running with `-XX:-OptimizePtrCompare` (which disables pointer comparison optimization), the compiler may hit an assertion failure in debug builds because `optimize_ptr_compare` is still being called. This violates the intended usage of the flag and leads to unexpected crashes. This patch adds an early return to `reduce_phi_on_cmp` when `OptimizePtrCompare` is false. Since the optimization relies on `optimize_ptr_compare` for static reasoning about comparisons, there's no benefit in proceeding with `reduce_phi_on_cmp` when this support is disabled.
👋 Welcome back hgqxjj! A progress list of the required criteria for merging this PR into |
@hgqxjj 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 4 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. 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, @JohnTortugo) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
src/hotspot/share/opto/escape.cpp
Outdated
if (!OptimizePtrCompare) { | ||
return; | ||
} |
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.
Thanks for working on this! IIUC, having the bailout here will fail to reduce the phi which could be unexpected. Shouldn't we just return UNKNOWN
from within ConnectionGraph::optimize_ptr_compare()
when we run without OptimizePtrCompare
?
On a separate note, can you also add a regression test? Maybe you can also just add a run with -XX:-OptimizePtrCompare
- maybe together with -XX:+VerifyReduceAllocationMerges
for more verification - to compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java
.
@JohnTortugo you might also want to have a look at this.
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.
Thanks a lot for your suggestion!
I took a closer look at the code, and I now fully agree that your approach is the better one. Returning UNKNOWN from optimize_ptr_compare() when OptimizePtrCompare is disabled makes the behavior more consistent and avoids skipping reduce_phi_on_cmp() entirely, which could lead to unexpected results or missed optimization opportunities. I appreciate your feedback and will move forward with this approach. Thanks again!
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.
Thanks for the ping @chhagedorn and I fully agree with your comment. Actually, that's the correct way to do this.
Thank you for fixing this @hgqxjj .
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.
hi @chhagedorn , I already update PR and add regression test. Please take another look when you have time .
Thanks a lot.
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.
Thanks for the update! I have some follow-up comments.
test/hotspot/jtreg/compiler/c2/TestReducePhiOnCmpWithNoOptPtrCompare.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/compiler/c2/TestReducePhiOnCmpWithNoOptPtrCompare.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/compiler/c2/TestReducePhiOnCmpWithNoOptPtrCompare.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/compiler/c2/TestReducePhiOnCmpWithNoOptPtrCompare.java
Outdated
Show resolved
Hide resolved
hi @chhagedorn ,thanks a lot for your detailed and thoughtful review. I'm still learning more about this area, and your feedback has been a great help. I've updated the PR based on your suggestions . Please feel free to let me know if anything else needs improvement. |
test/hotspot/jtreg/compiler/c2/TestReducePhiOnCmpWithNoOptPtrCompare.java
Outdated
Show resolved
Hide resolved
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, thanks! I'll give this a spinning in our testing and report back again.
|
/integrate |
@chhagedorn @JohnTortugo Thanks again for all your feedback. It’s been very helpful! If possible, could you please run /sponsor? |
Testing was clean 👍 /sponsor |
Going to push as commit 14c79be.
Your commit was automatically rebased without conflicts. |
@chhagedorn @hgqxjj Pushed as commit 14c79be. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
When running with
-XX:-OptimizePtrCompare
(which disables pointer comparison optimization), the compiler may hit an assertion failure in debug builds becauseoptimize_ptr_compare
is still being called. This violates the intended usage of the flag and leads to unexpected crashes.This patch adds an early return to
reduce_phi_on_cmp
whenOptimizePtrCompare
is false. Since the optimization relies onoptimize_ptr_compare
for static reasoning about comparisons, there's no benefit in proceeding withreduce_phi_on_cmp
when this flag is disabled.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26125/head:pull/26125
$ git checkout pull/26125
Update a local copy of the PR:
$ git checkout pull/26125
$ git pull https://git.openjdk.org/jdk.git pull/26125/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26125
View PR using the GUI difftool:
$ git pr show -t 26125
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26125.diff
Using Webrev
Link to Webrev Comment