Skip to content

Commit

Permalink
8325746: Refactor Loop Unswitching code
Browse files Browse the repository at this point in the history
Reviewed-by: epeter, kvn
  • Loading branch information
chhagedorn committed Feb 28, 2024
1 parent 4dd6c44 commit 6cad07c
Show file tree
Hide file tree
Showing 6 changed files with 464 additions and 183 deletions.
3 changes: 3 additions & 0 deletions src/hotspot/share/opto/cfgnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ class IfNode : public MultiBranchNode {
init_req(0,control);
init_req(1,b);
}

static IfNode* make_with_same_profile(IfNode* if_node_profile, Node* ctrl, BoolNode* bol);

virtual int Opcode() const;
virtual bool pinned() const { return true; }
virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
Expand Down
16 changes: 16 additions & 0 deletions src/hotspot/share/opto/ifnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,22 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) {
return new ConINode(TypeInt::ZERO);
}

IfNode* IfNode::make_with_same_profile(IfNode* if_node_profile, Node* ctrl, BoolNode* bol) {
// Assert here that we only try to create a clone from an If node with the same profiling if that actually makes sense.
// Some If node subtypes should not be cloned in this way. In theory, we should not clone BaseCountedLoopEndNodes.
// But they can end up being used as normal If nodes when peeling a loop - they serve as zero-trip guard.
// Allow them as well.
assert(if_node_profile->Opcode() == Op_If || if_node_profile->is_RangeCheck()
|| if_node_profile->is_BaseCountedLoopEnd(), "should not clone other nodes");
if (if_node_profile->is_RangeCheck()) {
// RangeCheck nodes could be further optimized.
return new RangeCheckNode(ctrl, bol, if_node_profile->_prob, if_node_profile->_fcnt);
} else {
// Not a RangeCheckNode? Fall back to IfNode.
return new IfNode(ctrl, bol, if_node_profile->_prob, if_node_profile->_fcnt);
}
}

// if this IfNode follows a range check pattern return the projection
// for the failed path
ProjNode* IfNode::range_check_trap_proj(int& flip_test, Node*& l, Node*& r) {
Expand Down
Loading

1 comment on commit 6cad07c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.