Skip to content

Commit

Permalink
Misc cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
chhagedorn committed Nov 16, 2023
1 parent 4a1e63b commit 3a240df
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 21 deletions.
7 changes: 4 additions & 3 deletions src/hotspot/share/opto/cfgnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class GotoNode : public Node {
virtual const RegMask &out_RegMask() const;
};

// This node represents a Template Assertion Predicate with two bools as input which can be used to create and
// This node represents a Template Assertion Predicate with two bools as input which can be used to create an
// Initialized Assertion Predicate from (more information can be found in the summary at predicates.hpp).
class TemplateAssertionPredicateNode : public Node {
int _initialized_init_value_opcode;
Expand Down Expand Up @@ -492,7 +492,8 @@ class IfNode : public MultiBranchNode {

class RangeCheckNode : public IfNode {
private:
int is_range_check(Node* &range, Node* &index, jint &offset);
int is_range_check(Node*& range, Node*& index, jint& offset);

public:
RangeCheckNode(Node* control, Node* bol, float p, float fcnt)
: IfNode(control, bol, p, fcnt) {
Expand All @@ -516,7 +517,7 @@ class RangeCheckNode : public IfNode {
// There are three kinds of Parse Predicates:
// Loop Parse Predicate, Profiled Loop Parse Predicate (both used by Loop Predication), and Loop Limit Check Parse
// Predicate (used for integer overflow checks when creating a counted loop).
// More information about predicates can be found in loopPredicate.cpp.
// More information about predicates can be found in predicates.hpp.
class ParsePredicateNode : public IfNode {
Deoptimization::DeoptReason _deopt_reason;
bool _useless; // If the associated loop dies, this parse predicate becomes useless and can be cleaned up by Value().
Expand Down
18 changes: 10 additions & 8 deletions src/hotspot/share/opto/loopPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ bool IdealLoopTree::is_range_check_if(IfProjNode* if_success_proj, PhaseIdealLoo
// (2) stride*scale < 0
// max(scale*i + offset) = scale*init + offset
BoolNode* PhaseIdealLoop::rc_predicate(Node* ctrl, const int scale, Node* offset, Node* init, Node* limit,
const jint stride, Node* range, const bool upper, bool &overflow) {
const jint stride, Node* range, const bool upper, bool& overflow) {
jint con_limit = (limit != nullptr && limit->is_Con()) ? limit->get_int() : 0;
jint con_init = init->is_Con() ? init->get_int() : 0;
jint con_offset = offset->is_Con() ? offset->get_int() : 0;
Expand Down Expand Up @@ -1000,10 +1000,8 @@ void PhaseIdealLoop::loop_predication_follow_branches(Node *n, IdealLoopTree *lo
bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNode* if_success_proj,
ParsePredicateSuccessProj* parse_predicate_proj, CountedLoopNode* cl,
ConNode* zero, Invariance& invar, Deoptimization::DeoptReason reason) {
// Following are changed to nonnull when a predicate can be hoisted
Node* new_predicate_tail = nullptr;
IfNode* iff = if_success_proj->in(0)->as_If();
Node* test = iff->in(1);
IfNode* iff = if_success_proj->in(0)->as_If();
Node* test = iff->in(1);
if (!test->is_Bool()) { // Conv2B, ...
return false;
}
Expand Down Expand Up @@ -1085,7 +1083,9 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
IfNode* lower_bound_iff = lower_bound_proj->in(0)->as_If();
_igvn.hash_delete(lower_bound_iff);
lower_bound_iff->set_req(1, lower_bound_bol);
if (TraceLoopPredicate) tty->print_cr("lower bound check if: %d", lower_bound_iff->_idx);
if (TraceLoopPredicate) {
tty->print_cr("lower bound check if: %d", lower_bound_iff->_idx);
}

// Test the upper bound
BoolNode* upper_bound_bol = rc_predicate(lower_bound_proj, scale, offset, init, limit, stride, rng, true, overflow);
Expand All @@ -1095,7 +1095,9 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
IfNode* upper_bound_iff = upper_bound_proj->in(0)->as_If();
_igvn.hash_delete(upper_bound_iff);
upper_bound_iff->set_req(1, upper_bound_bol);
if (TraceLoopPredicate) tty->print_cr("upper bound check if: %d", lower_bound_iff->_idx);
if (TraceLoopPredicate) {
tty->print_cr("upper bound check if: %d", upper_bound_iff->_idx);
}

// Each newly created Hoisted Check Predicate is accompanied by two Template Assertion Predicates. Later, we initialize
// them by making a copy of them when splitting a loop into sub loops. The Assertion Predicates ensure that dead sub
Expand Down Expand Up @@ -1293,7 +1295,7 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree* loop) {
return hoisted;
}

// We cannot add Loop Predicates if:
// We cannot create Loop Predicates if:
// (1) There is no Loop Parse Predicate.
// (2) Already added Profiled Loop Predicates (Loop Predicates and Profiled Loop Predicates can be dependent
// through a data node, and thus we should only add new Profiled Loop Predicates which are below Loop Predicates
Expand Down
7 changes: 2 additions & 5 deletions src/hotspot/share/opto/loopUnswitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,12 @@ class OriginalLoop {
#endif // ASSERT
};

//-------------------------create_slow_version_of_loop------------------------
// Create a slow version of the loop by cloning the loop
// and inserting an if to select fast-slow versions.
// Return the inserted if.
// Create a slow version of the loop by cloning the loop and inserting an If to select the fast or slow version.
// Return the inserted loop selector If.
IfNode* PhaseIdealLoop::create_slow_version_of_loop(IdealLoopTree* loop, Node_List& old_new,
IfNode* unswitching_candidate) {
OriginalLoop original_loop(loop, &old_new);
IfNode* loop_selector_if = original_loop.unswitch(unswitching_candidate);
recompute_dom_depth();
return loop_selector_if;
}

1 change: 0 additions & 1 deletion src/hotspot/share/opto/loopnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,6 @@ class PhaseIdealLoop : public PhaseTransform {
Deoptimization::DeoptReason reason, int opcode,
bool rewire_uncommon_proj_phi_inputs = false);


private:
// Helper functions for create_new_if_for_predicate()
void set_ctrl_of_nodes_with_same_ctrl(Node* node, ProjNode* old_ctrl, Node* new_ctrl);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/opto/predicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,12 @@ class CreateInitializedAssertionPredicate {
// Create the out nodes of a newly created Initialized Assertion Predicate If node which includes the projections and
// the dedicated Halt node.
IfTrueNode* create_if_proj_nodes(IfNode* if_node, IdealLoopTree* loop) {
IfTrueNode* succ_proj = new IfTrueNode(if_node);
IfTrueNode* success_proj = new IfTrueNode(if_node);
IfFalseNode* fail_proj = new IfFalseNode(if_node);
_phase->register_control(succ_proj, loop, if_node);
_phase->register_control(success_proj, loop, if_node);
_phase->register_control(fail_proj, loop, if_node);
create_halt_node(fail_proj, loop);
return succ_proj;
return success_proj;
}
public:
explicit CreateInitializedAssertionPredicate(PhaseIdealLoop* phase) : _phase(phase) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@

/*
* @test id=NoFlags
* @key randomness
* @bug 8288981
* @run driver compiler.predicates.TestAssertionPredicates NoFlags
*/
Expand Down

0 comments on commit 3a240df

Please sign in to comment.