Skip to content

8334571: Extract control dependency rewiring out of PhaseIdealLoop::dominated_by() into separate method #19806

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

Closed
wants to merge 3 commits into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Jun 20, 2024

This is another patch split off from the full Assertion Predicates fix.

PhaseIdealLoop::dominated_by() only works for an IfNode that dominates another IfNode. However, at some point, we want to replace the two IfNodes that are generated as Template Assertion Predicate for a hoisted range check with a single dedicated TemplateAssertionPredicateNode. To still be able to rewire the control dependencies in Loop Predication from the hoisted range check to the new TemplateAssertionPredicateNode outside the loop (instead of to the second IfNode projection of the Template Assertion Predicate as done today), we can extract the rewiring part out of dominated_by() into a separate method rewire_safe_outputs_to_dominator() and use that one instead.

We get the following in Loop Predication:

  • Invariant checks: Still use dominated_by() which calls rewire_safe_outputs_to_dominator()
  • Range checks: Use eliminate_hoisted_range_check() which calls rewire_safe_outputs_to_dominator().

Thanks,
Christian


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-8334571: Extract control dependency rewiring out of PhaseIdealLoop::dominated_by() into separate method (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19806

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 20, 2024

👋 Welcome back chagedorn! 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 Jun 20, 2024

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

8334571: Extract control dependency rewiring out of PhaseIdealLoop::dominated_by() into separate method

Reviewed-by: roland, kvn

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

  • a4582a8: 8334166: Enable binary check
  • 7baddc2: 8334339: Test java/nio/file/attribute/BasicFileAttributeView/CreationTime.java fails on alinux3
  • eb110bd: 8334180: NMT gtests introduced with 8312132 should be labeled as NMT
  • 652784c: 8334392: Switch RNG in NMT's treap
  • 72ca7ba: 8334708: FFM: two javadoc problems
  • 7e55ed3: 8333748: javap crash - Fatal error: Unmatched bit position 0x2 for location CLASS
  • 1ff5acd: 8332099: since-checker - Add @ since to package-info in jdk.jsobject
  • 689cee3: 8334509: Cancelling PageDialog does not return the same PageFormat object
  • 8e1d2b0: 8334441: Mark tests in jdk_security_infra group as manual
  • 93d9802: 8334715: [riscv] Mixed use of tab and whitespace in riscv.ad
  • ... and 35 more: https://git.openjdk.org/jdk/compare/50bed6c67b1edd7736bdf79308d135a4e1047ff0...master

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 master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Jun 20, 2024

@chhagedorn 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 Jun 20, 2024
// Eliminate the old If in the loop body.
dominated_by(hoisted_check_predicate_proj, iff, negated);

C->print_method(PHASE_AFTER_LOOP_PREDICATION_IC, 4, hoisted_check_predicate_proj->in(0));
Copy link
Member Author

Choose a reason for hiding this comment

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

Additional benefit: This now dumps the graph after eliminating the hoisted check out of the loop. Same for the range checks.

Comment on lines +362 to +389
for (DUIterator_Fast imax, i = source->fast_outs(imax); i < imax; i++) {
Node* out = source->fast_out(i); // Control-dependent node
// Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check.
if (cd->depends_only_on_test() && _igvn.no_dependent_zero_check(cd)) {
assert(cd->in(0) == dp, "");
_igvn.replace_input_of(cd, 0, prevdom);
if (out->depends_only_on_test() && _igvn.no_dependent_zero_check(out)) {
assert(out->in(0) == source, "must be control dependent on source");
_igvn.replace_input_of(out, 0, dominator);
if (pin_array_access_nodes) {
// Because of Loop Predication, Loads and range check Cast nodes that are control dependent on this range
// check (that is about to be removed) now depend on multiple dominating Hoisted Check Predicates. After the
// removal of this range check, these control dependent nodes end up at the lowest/nearest dominating predicate
// in the graph. To ensure that these Loads/Casts do not float above any of the dominating checks (even when the
// lowest dominating check is later replaced by yet another dominating check), we need to pin them at the lowest
// dominating check.
Node* clone = cd->pin_array_access_node();
Node* clone = out->pin_array_access_node();
if (clone != nullptr) {
clone = _igvn.register_new_node_with_optimizer(clone, cd);
_igvn.replace_node(cd, clone);
cd = clone;
clone = _igvn.register_new_node_with_optimizer(clone, out);
_igvn.replace_node(out, clone);
out = clone;
}
}
set_early_ctrl(cd, false);
IdealLoopTree* new_loop = get_loop(get_ctrl(cd));
set_early_ctrl(out, false);
IdealLoopTree* new_loop = get_loop(get_ctrl(out));
if (old_loop != new_loop) {
if (!old_loop->_child) {
old_loop->_body.yank(cd);
old_loop->_body.yank(out);
}
if (!new_loop->_child) {
new_loop->_body.push(cd);
new_loop->_body.push(out);
Copy link
Member Author

Choose a reason for hiding this comment

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

Renaming only and adding assertion message

void PhaseIdealLoop::eliminate_hoisted_range_check(IfTrueNode* hoisted_check_proj,
IfTrueNode* template_assertion_predicate_proj) {
_igvn.replace_input_of(hoisted_check_proj->in(0), 1, _igvn.intcon(1));
rewire_safe_outputs_to_dominator(hoisted_check_proj, template_assertion_predicate_proj, true);
Copy link
Member Author

Choose a reason for hiding this comment

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

pin_array_access_nodes = true since this is called only for range checks now.

@@ -1281,24 +1292,21 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
// with uncommon trap.
return false;
}
assert(new_predicate_proj != nullptr, "sanity");
// Success - attach condition (new_predicate_bol) to predicate if
invar.map_ctrl(if_success_proj, new_predicate_proj); // so that invariance test can be appropriate
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to invariant checks and range checks separately.

@chhagedorn chhagedorn marked this pull request as ready for review June 20, 2024 14:38
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 20, 2024
@mlbridge
Copy link

mlbridge bot commented Jun 20, 2024

Webrevs

Copy link
Contributor

@rwestrel rwestrel left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 20, 2024
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Looks good.

@chhagedorn
Copy link
Member Author

Thanks Roland and Vladimir for your reviews!

@chhagedorn
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 24, 2024

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

  • 05ff318: 8334594: Generational ZGC: Deadlock after OopMap rewrites in 8331572
  • 05a63d8: 8334489: Add function os::used_memory
  • edf7f05: 8334083: C2 SuperWord: TestCompatibleUseDefTypeSize.java fails with -XX:+AlignVector after JDK-8325155
  • 13dce29: 8334560: [PPC64]: postalloc_expand_java_dynamic_call_sched does not copy all fields
  • 863b2a9: 8329994: Zap alignment padding bits for ArrayOops in non-release builds
  • a4582a8: 8334166: Enable binary check
  • 7baddc2: 8334339: Test java/nio/file/attribute/BasicFileAttributeView/CreationTime.java fails on alinux3
  • eb110bd: 8334180: NMT gtests introduced with 8312132 should be labeled as NMT
  • 652784c: 8334392: Switch RNG in NMT's treap
  • 72ca7ba: 8334708: FFM: two javadoc problems
  • ... and 40 more: https://git.openjdk.org/jdk/compare/50bed6c67b1edd7736bdf79308d135a4e1047ff0...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 24, 2024
@openjdk openjdk bot closed this Jun 24, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 24, 2024
@openjdk
Copy link

openjdk bot commented Jun 24, 2024

@chhagedorn Pushed as commit ca5a438.

💡 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
Development

Successfully merging this pull request may close these issues.

3 participants