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

8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor #22828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Dec 19, 2024

This patch is a follow up to the clean-ups done with JDK-8342945 and introduces a new predicate visitor for Loop Unswitching to update the last remaining custom predicate cloning code.

This patch includes the following:

  • New CloneUnswitchedLoopPredicatesVisitor class which delegates the cloning work to a new ClonePredicateToTargetLoop class.

    • We walk the predicate chain in the PredicateIterator and call the CloneUnswitchedLoopPredicatesVisitor for each visited predicate. Then we clone the predicate on the fly to the target loop.
  • New ClonePredicateToTargetLoop class:

    • Clones Parse Predicates
    • Clones Template Assertion Predicates
      • Includes rewiring of control dependent data nodes
    • Rewires the cloned predicates to the target loop with new TargetLoopPredicateChain class:
      • Keeps track of the current chain head, which is the target loop itself when the chain is still empty.
      • Each time a new predicate is inserted at the target loop, the old predicate chain head is set as output of the new predicate.
      • An example is shown as class comment at TargetLoopPredicateChain.
      • I plan to reuse this class later again when also updating CreateAssertionPredicatesVisitor which is done when we tackle the actual still remaining Assertion Predicate bugs.
  • Removal of custom predicate cloning code found in PhaseIdealLoop.

  • Changed steps performed in Loop Unswitching from:

    1. Clone loop
    2. Clone predicates and insert them below the unswitched loop selector If projections
    3. Connect the cloned predicates to the unswitched loops

    to:

    1. Clone loop
    2. Connect unswitched loop selector If projections to unswitched loops such that they are now the new loop entries
    3. Clone predicates and insert them between the unswitched loop selector If projections and the unswitched loops
  • Rename/update get_template_assertion_predicates()/TemplateAssertionPredicateCollector to reflect the only use left.

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-8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor (Sub-task - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22828

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 19, 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 Dec 19, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Dec 19, 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.

const int opcode, const bool rewire_uncommon_proj_phi_inputs,
AssertionPredicateType assertion_predicate_type) {
const int opcode, const bool rewire_uncommon_proj_phi_inputs) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Squeezed this in here: assertion_predicate_type is dead.

Comment on lines +273 to +274
void PhaseIdealLoop::get_opaque_template_assertion_predicate_nodes(ParsePredicateSuccessProj* parse_predicate_proj,
Unique_Node_List& list) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Only applied a renaming here.

Comment on lines +241 to +250
void unswitch(const UnswitchedLoopSelector& unswitched_loop_selector) {
const uint first_false_path_loop_node_index = _phase->C->unique();
clone_loop(unswitched_loop_selector);

move_parse_and_template_assertion_predicates_to_unswitched_loops(unswitched_loop_selector,
first_false_path_loop_node_index);
DEBUG_ONLY(verify_unswitched_loop_versions(_loop->_head->as_Loop(), unswitched_loop_selector);)

_phase->recompute_dom_depth();
remove_unswitch_candidate_from_loops(unswitched_loop_selector);
Copy link
Member Author

Choose a reason for hiding this comment

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

New order of operation (see PR description).

Comment on lines +271 to +279
const UnswitchedLoopSelector& unswitched_loop_selector, const uint first_false_path_loop_node_index) const {
const NodeInOriginalLoopBody node_in_true_path_loop_body(first_false_path_loop_node_index, _old_new);
const NodeInClonedLoopBody node_in_false_path_loop_body(first_false_path_loop_node_index);
CloneUnswitchedLoopPredicatesVisitor
clone_unswitched_loop_predicates_visitor(_loop_head, old_to_new(_loop_head)->as_Loop(), node_in_true_path_loop_body,
node_in_false_path_loop_body, _phase);
Node* source_loop_entry = unswitched_loop_selector.selector()->in(0);
PredicateIterator predicate_iterator(source_loop_entry);
predicate_iterator.for_each(clone_unswitched_loop_predicates_visitor);
Copy link
Member Author

Choose a reason for hiding this comment

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

The main part that is new here: We use visitors to clone the predicates and rewire them correctly.

Comment on lines +298 to +300
Node* old_to_new(const Node* old) const {
return _old_new[old->_idx];
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Only moved.

@chhagedorn chhagedorn marked this pull request as ready for review December 19, 2024 14:00
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 19, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 19, 2024

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler [email protected] rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

1 participant