Skip to content

Commit

Permalink
more cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
chhagedorn committed Nov 23, 2023
1 parent 764e1a1 commit 0b5956a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 30 deletions.
12 changes: 11 additions & 1 deletion src/hotspot/share/opto/cfgnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2840,13 +2840,23 @@ IfNode* TemplateAssertionPredicateNode::create_initialized_assertion_predicate(
create_if_node = _initialized_last_value_opcode == Op_If;
break;
default:
assert(false, "should not reach");
assert(false, "invalid Assertion Predicate type");
}
return create_if_node ?
new IfNode(control, opaque_bool, PROB_MAX, COUNT_UNKNOWN NOT_PRODUCT(COMMA initialized_assertion_predicate_type)) :
new RangeCheckNode(control, opaque_bool, PROB_MAX, COUNT_UNKNOWN NOT_PRODUCT(COMMA initialized_assertion_predicate_type));
}


uint TemplateAssertionPredicateNode::index_for_bool_input(const BoolNode* bool_input) const {
if (bool_input == in(TemplateAssertionPredicateNode::InitValue)) {
return TemplateAssertionPredicateNode::InitValue;
} else {
assert(bool_input == in(TemplateAssertionPredicateNode::LastValue), "must be a bool input");
return TemplateAssertionPredicateNode::LastValue;
}
}

Node* TemplateAssertionPredicateNode::Identity(PhaseGVN* phase) {
if (phase->C->post_loop_opts_phase() || _useless) {
return in(0);
Expand Down
19 changes: 6 additions & 13 deletions src/hotspot/share/opto/cfgnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#ifndef SHARE_OPTO_CFGNODE_HPP
#define SHARE_OPTO_CFGNODE_HPP

#include "opaquenode.hpp"
#include "opto/multnode.hpp"
#include "opto/node.hpp"
#include "opto/opcodes.hpp"
Expand Down Expand Up @@ -57,6 +56,7 @@ class CatchProjNode;
class JProjNode;
class JumpProjNode;
class SCMemProjNode;
class OpaqueAssertionPredicateNode;
class PhaseIdealLoop;
enum class AssertionPredicateType;

Expand Down Expand Up @@ -309,13 +309,15 @@ class TemplateAssertionPredicateNode : public Node {

TemplateAssertionPredicateNode(Node* control, BoolNode* bool_init_value, BoolNode* bool_last_value,
int initialized_init_value_opcode, int initialized_last_value_opcode);
IfNode* create_initialized_assertion_predicate(Node* control, OpaqueAssertionPredicateNode* opaque_bool,
AssertionPredicateType initialized_assertion_predicate_type) const;

void mark_useless() {
_useless = true;
}

IfNode* create_initialized_assertion_predicate(Node* control, OpaqueAssertionPredicateNode* opaque_bool,
AssertionPredicateType initialized_assertion_predicate_type) const;
uint index_for_bool_input(const BoolNode* bool_input) const;

virtual int Opcode() const;
virtual bool pinned() const { return true; }
virtual bool is_CFG() const { return true; }
Expand All @@ -325,15 +327,6 @@ class TemplateAssertionPredicateNode : public Node {
virtual Node* Identity(PhaseGVN* phase);
virtual const Type* Value(PhaseGVN* phase) const;

uint index_for_bool_input(const BoolNode* bool_input) const {
if (bool_input == in(TemplateAssertionPredicateNode::InitValue)) {
return TemplateAssertionPredicateNode::InitValue;
} else {
assert(bool_input == in(TemplateAssertionPredicateNode::LastValue), "must be a bool input");
return TemplateAssertionPredicateNode::LastValue;
}
}

NOT_PRODUCT(void dump_spec(outputStream* st) const;)
};

Expand Down Expand Up @@ -371,7 +364,7 @@ class IfNode : public MultiBranchNode {
float _fcnt; // Frequency counter

private:
AssertionPredicateType _assertion_predicate_type;
NOT_PRODUCT(AssertionPredicateType _assertion_predicate_type;)

void init_node(Node* control, Node* bol) {
init_class_id(Class_If);
Expand Down
17 changes: 8 additions & 9 deletions src/hotspot/share/opto/loopPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ void PhaseIdealLoop::register_control(Node* n, IdealLoopTree *loop, Node* pred,
}
}

//------------------------------create_new_if_for_predicate------------------------
// create a new if above the uct_if_pattern for the predicate to be promoted.
// Creates a new if-cont-else- above the uct_if_pattern for the predicate to be promoted.
//
// before after
// ---------- ----------
Expand Down Expand Up @@ -1127,11 +1126,11 @@ bool PhaseIdealLoop::loop_predication_impl_helper(IdealLoopTree* loop, IfProjNod
}

void PhaseIdealLoop::eliminate_old_range_check(IfProjNode* if_proj,
TemplateAssertionPredicateNode* template_assertion_predicate_node) {
TemplateAssertionPredicateNode* template_assertion_predicate) {
ConINode* true_con = _igvn.intcon(1);
set_ctrl(true_con, C->root());
_igvn.replace_input_of(if_proj->in(0), 1, true_con);
rewire_safe_outputs_to_dominator(if_proj, template_assertion_predicate_node);
rewire_safe_outputs_to_dominator(if_proj, template_assertion_predicate);
}

// Insert Hoisted Check Predicates for null checks and range checks and additional Template Assertion Predicates for
Expand All @@ -1144,10 +1143,6 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree* loop) {
return false;
}

if (head->is_OuterStripMinedLoop()) {
return false;
}

CountedLoopNode *cl = nullptr;
if (head->is_valid_counted_loop(T_INT)) {
cl = head->as_CountedLoop();
Expand Down Expand Up @@ -1343,5 +1338,9 @@ bool IdealLoopTree::loop_predication(PhaseIdealLoop* phase) {
}

bool IdealLoopTree::can_apply_loop_predication() {
return !_head->is_Root() && _head->is_Loop() && !_irreducible && !tail()->is_top();
return !_head->is_Root() &&
_head->is_Loop() &&
!_head->is_OuterStripMinedLoop() &&
!_irreducible &&
!tail()->is_top();
}
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/loopTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*
*/

#include "compile.hpp"
#include "precompiled.hpp"
#include "compiler/compileLog.hpp"
#include "memory/allocation.inline.hpp"
Expand Down Expand Up @@ -690,6 +689,7 @@ void PhaseIdealLoop::peeled_dom_test_elim(IdealLoopTree* loop, Node_List& old_ne
// exit
//
void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) {

C->set_major_progress();
// Peeling a 'main' loop in a pre/main/post situation obfuscates the
// 'pre' loop from the main and the 'pre' can no longer have its
Expand Down Expand Up @@ -1602,7 +1602,7 @@ void PhaseIdealLoop::insert_vector_post_loop(IdealLoopTree *loop, Node_List &old

//------------------------------insert_post_loop-------------------------------
// Insert post loops. Add a post loop to the given loop passed.
Node *PhaseIdealLoop::insert_post_loop(IdealLoopTree* loop, Node_List& old_new, CountedLoopNode* main_head,
Node* PhaseIdealLoop::insert_post_loop(IdealLoopTree* loop, Node_List& old_new, CountedLoopNode* main_head,
CountedLoopEndNode* main_end, CountedLoopNode*& post_head) {
IfNode* outer_main_end = main_end;
IdealLoopTree* outer_loop = loop;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/loopnode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ class PhaseIdealLoop : public PhaseTransform {
Node *has_local_phi_input( Node *n );
// Mark an IfNode as being dominated by a prior test,
// without actually altering the CFG (and hence IDOM info).
void dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip = false, bool exclude_loop_predicate = false);
void dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip = false, bool exclude_predicates = false);
void rewire_safe_outputs_to_dominator(Node* source, Node* dominator);

// Split Node 'n' through merge point
Expand Down Expand Up @@ -1689,7 +1689,7 @@ class PhaseIdealLoop : public PhaseTransform {

bool can_move_to_inner_loop(Node* n, LoopNode* n_loop, Node* x);
void eliminate_old_range_check(IfProjNode* if_proj,
TemplateAssertionPredicateNode* template_assertion_predicate_node);
TemplateAssertionPredicateNode* template_assertion_predicate);
};


Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/loopopts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool PhaseIdealLoop::loop_phi_backedge_type_contains_zero(const Node* phi_diviso
// Replace the dominated test with an obvious true or false. Place it on the
// IGVN worklist for later cleanup. Move control-dependent data Nodes on the
// live path up to the dominating control.
void PhaseIdealLoop::dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip, bool exclude_loop_predicate) {
void PhaseIdealLoop::dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip, bool exclude_predicates) {
if (VerifyLoopOptimizations && PrintOpto) { tty->print_cr("dominating test"); }

// prevdom is the dominating projection of the dominating test.
Expand Down Expand Up @@ -349,7 +349,7 @@ void PhaseIdealLoop::dominated_by(IfProjNode* prevdom, IfNode* iff, bool flip, b

ProjNode* dp_proj = dp->as_Proj();
ProjNode* unc_proj = iff->proj_out(1 - dp_proj->_con)->as_Proj();
if (exclude_loop_predicate &&
if (exclude_predicates &&
(unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != nullptr ||
unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_profile_predicate) != nullptr ||
unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_range_check) != nullptr)) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/predicates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ParsePredicateUsefulMarker : public PredicateVisitor {
// Mark all Parse Predicates 'loop' as useful. If 'loop' represents an outer strip mined loop, we can skip it because
// we have already processed the predicates before when we visited its counted (inner) loop.
void EliminateUselessParsePredicates::mark_parse_predicates_useful(IdealLoopTree* loop) {
if (loop->can_apply_loop_predication() && !loop->_head->is_OuterStripMinedLoop()) {
if (loop->can_apply_loop_predication()) {
ParsePredicateUsefulMarker useful_marker;
Node* entry = loop->_head->as_Loop()->skip_strip_mined()->in(LoopNode::EntryControl);
PredicatesForLoop predicates_for_loop(entry, &useful_marker);
Expand Down

0 comments on commit 0b5956a

Please sign in to comment.