Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
  • Loading branch information
chhagedorn and eme64 authored Feb 14, 2024
1 parent f73c5fb commit 17c27a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/opto/ifnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ IfNode* IfNode::make_with_same_profile(IfNode* if_node_profile, Node* ctrl, Bool
if (if_node_profile->Opcode() == Op_If) {
return new IfNode(ctrl, bol, if_node_profile->_prob, if_node_profile->_fcnt);
} else {
assert(if_node_profile->Opcode() == Op_RangeCheck, "only IfNode or RangeCheckNode expected");
return new RangeCheckNode(ctrl, bol, if_node_profile->_prob, if_node_profile->_fcnt);
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/hotspot/share/opto/loopUnswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class UnswitchedLoopSelector : public StackObj {
private:
IfNode* find_unswitch_candidate(IdealLoopTree* loop) {
IfNode* unswitch_candidate = _phase->find_unswitch_candidate(loop);
assert(unswitch_candidate != nullptr, "must exist");
assert(unswitch_candidate != nullptr, "guaranteed to exist by policy_unswitching");
assert(_phase->is_member(loop, unswitch_candidate), "must be inside original loop");
return unswitch_candidate;
}
Expand Down Expand Up @@ -356,19 +356,20 @@ void PhaseIdealLoop::hoist_invariant_check_casts(const IdealLoopTree* loop, cons
const UnswitchedLoopSelector& unswitched_loop_selector) {
IfNode* unswitch_candidate = unswitched_loop_selector.unswitch_candidate();
IfNode* loop_selector = unswitched_loop_selector.selector();
Node_List worklist;
ResourceMark rm;
GrowableArray<CheckCastPPNode*> loop_invariant_check_casts;
for (DUIterator_Fast imax, i = unswitch_candidate->fast_outs(imax); i < imax; i++) {
IfProjNode* proj = unswitch_candidate->fast_out(i)->as_IfProj();
// Copy to a worklist for easier manipulation
for (DUIterator_Fast jmax, j = proj->fast_outs(jmax); j < jmax; j++) {
Node* use = proj->fast_out(j);
if (use->Opcode() == Op_CheckCastPP && loop->is_invariant(use->in(1))) {
worklist.push(use);
Node* check_cast = proj->fast_out(j)->isa_CheckCastPP();
if (check_cast != nullptr && loop->is_invariant(check_cast->in(1))) {
loop_invariant_check_casts.push(check_cast);
}
}
IfProjNode* loop_selector_if_proj = loop_selector->proj_out(proj->_con)->as_IfProj();
while (worklist.size() > 0) {
Node* cast = worklist.pop();
while (loop_invariant_check_casts.size() > 0) {
CheckCastPPNode* cast = loop_invariant_check_casts.pop();
Node* cast_clone = cast->clone();
cast_clone->set_req(0, loop_selector_if_proj);
_igvn.replace_input_of(cast, 1, cast_clone);
Expand All @@ -384,8 +385,8 @@ void PhaseIdealLoop::hoist_invariant_check_casts(const IdealLoopTree* loop, cons
void PhaseIdealLoop::add_unswitched_loop_version_bodies_to_igvn(IdealLoopTree* loop, const Node_List& old_new) {
loop->record_for_igvn();
for(int i = loop->_body.size() - 1; i >= 0 ; i--) {
Node *n = loop->_body[i];
Node *n_clone = old_new[n->_idx];
Node* n = loop->_body[i];
Node* n_clone = old_new[n->_idx];
_igvn._worklist.push(n_clone);
}
}
Expand Down

0 comments on commit 17c27a5

Please sign in to comment.