-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8301489: C1: ShortLoopOptimizer might lift instructions before their inputs #14492
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
|
👋 Welcome back danielogh! A progress list of the required criteria for merging this PR into |
|
@danielogh 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
|
TobiHartmann
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.
Great work investigating this, Daniel!
From your comments in JBS, it seems that the underlying issue is additional exception edges in the graph that affect dominator computation. Could you elaborate a bit more on that with respect to the example that you provided in the PR description?
I'm not an expert in C1 though (paging @veresov and @rwestrel as the author of JDK-7153771).
Thanks,
Tobias
src/hotspot/share/c1/c1_ValueMap.cpp
Outdated
| #ifdef ASSERT | ||
| assert(insert != nullptr, "insertion point should not be null"); | ||
| #endif |
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.
| #ifdef ASSERT | |
| assert(insert != nullptr, "insertion point should not be null"); | |
| #endif | |
| assert(insert != nullptr, "insertion point should not be null"); |
src/hotspot/share/c1/c1_ValueMap.cpp
Outdated
| } | ||
|
|
||
| public: | ||
| bool is_valid() {return _valid; } |
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.
| bool is_valid() {return _valid; } | |
| bool is_valid() { return _valid; } |
| Value _insert; | ||
| bool _valid = true; | ||
|
|
||
| void visit(Value* vp) { |
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.
Since Value is already a pointer type, can't we use Value v here?
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.
I am not sure if this is possible without changing the ValueVisitor (ref) itself
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.
Right, makes sense.
robcasloz
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.
Good catch, analysis, and regression test Daniel. Great that you could generalize the fix to cover all other LICM cases. Just a couple of comments/suggestions.
src/hotspot/share/c1/c1_ValueMap.cpp
Outdated
| } | ||
| } | ||
|
|
||
| class CheckInsertionPoint: public ValueVisitor { |
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.
For consistency with other similar cases in c1_ValueMap.cpp:
| class CheckInsertionPoint: public ValueVisitor { | |
| class CheckInsertionPoint : public ValueVisitor { |
src/hotspot/share/c1/c1_ValueMap.cpp
Outdated
| CheckInsertionPoint v(_insertion_point); | ||
| cur->input_values_do(&v); |
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.
For compilation efficiency, would it be possible to perform this computation only when cur_invariant holds? You could for example encapsulate the creation of v, call to cur->input_values_do(&v), and v.is_valid() check into an auxiliary function is_dominated_by_inputs(_insertion_point, cur) or similar and call that function below (if (cur_invariant && is_dominated_by_inputs(_insertion_point, cur)) {).
Thank you very much for review! My understanding is, this might have been introduced in JDK-7153771, where we have extra edges to the exception handler of all successors during dominator calculation -- |
robcasloz
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.
Thanks for addressing the suggestions and for the additional explanation, looks good!
|
@danielogh 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 148 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 (@TobiHartmann, @robcasloz) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
TobiHartmann
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.
|
/integrate |
|
@danielogh |
|
Thanks Roberto and Tobias for review. Thanks Roberto for additional help with PR. |
|
/sponsor |
|
Going to push as commit 73d7aa1.
Your commit was automatically rebased without conflicts. |
|
@TobiHartmann @danielogh Pushed as commit 73d7aa1. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
ShortLoopOptimizer might lift instructions before their inputs on some graph shapes. We propose adding a check that the insertion point for an instruction that is a candidate for hoisting should not be higher up the dominator tree than any inputs to the instruction.
Testing: tier1-tier3.
Additional testing: observed that
(cur_invariant && !v.is_valid())never occurs on tier1-tier3 before the added test case.Also verified that the depth check is equivalent to
(*vp->block() == _insert->block()) || dominates(*vp, _insert)on all of tier1-tier3.Failure case: in the attached image the
arraylengthinstruction from B10 is lifted to B0, as the dominator of B10 is calculated as B0. This is based on the logic inComputeLinearScanOrder::compute_dominator_impl. But the array input is in Block 3. This is later spotted inc1_LIRAssembler.cppwithError: ShouldNotReachHere(). We can reproduce the error on other instructions too -- the reader may refer to the test case provided.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14492/head:pull/14492$ git checkout pull/14492Update a local copy of the PR:
$ git checkout pull/14492$ git pull https://git.openjdk.org/jdk.git pull/14492/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14492View PR using the GUI difftool:
$ git pr show -t 14492Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14492.diff
Webrev
Link to Webrev Comment