From 0b5956a54c766faca6b2428434ab83cf7c4f1bb8 Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Thu, 23 Nov 2023 14:31:15 +0100 Subject: [PATCH] more cleanups --- src/hotspot/share/opto/cfgnode.cpp | 12 +++++++++++- src/hotspot/share/opto/cfgnode.hpp | 19 ++++++------------- src/hotspot/share/opto/loopPredicate.cpp | 17 ++++++++--------- src/hotspot/share/opto/loopTransform.cpp | 4 ++-- src/hotspot/share/opto/loopnode.hpp | 4 ++-- src/hotspot/share/opto/loopopts.cpp | 4 ++-- src/hotspot/share/opto/predicates.cpp | 2 +- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/hotspot/share/opto/cfgnode.cpp b/src/hotspot/share/opto/cfgnode.cpp index f8ffe054e1afb..948c1189c7846 100644 --- a/src/hotspot/share/opto/cfgnode.cpp +++ b/src/hotspot/share/opto/cfgnode.cpp @@ -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); diff --git a/src/hotspot/share/opto/cfgnode.hpp b/src/hotspot/share/opto/cfgnode.hpp index 6d1a9e9ff52c0..061d8ac85ce41 100644 --- a/src/hotspot/share/opto/cfgnode.hpp +++ b/src/hotspot/share/opto/cfgnode.hpp @@ -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" @@ -57,6 +56,7 @@ class CatchProjNode; class JProjNode; class JumpProjNode; class SCMemProjNode; +class OpaqueAssertionPredicateNode; class PhaseIdealLoop; enum class AssertionPredicateType; @@ -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; } @@ -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;) }; @@ -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); diff --git a/src/hotspot/share/opto/loopPredicate.cpp b/src/hotspot/share/opto/loopPredicate.cpp index dbab17ecb6082..358fb00a2128d 100644 --- a/src/hotspot/share/opto/loopPredicate.cpp +++ b/src/hotspot/share/opto/loopPredicate.cpp @@ -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 // ---------- ---------- @@ -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 @@ -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(); @@ -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(); } diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 445bee5ab3dc0..b25a3a7066d72 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -22,7 +22,6 @@ * */ -#include "compile.hpp" #include "precompiled.hpp" #include "compiler/compileLog.hpp" #include "memory/allocation.inline.hpp" @@ -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 @@ -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; diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index 76812b19172db..fdd390975f7b3 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -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 @@ -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); }; diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index a34e525e5cf9d..17cac4a2c28ae 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -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. @@ -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)) { diff --git a/src/hotspot/share/opto/predicates.cpp b/src/hotspot/share/opto/predicates.cpp index fe55637be2997..5b74fff7143c8 100644 --- a/src/hotspot/share/opto/predicates.cpp +++ b/src/hotspot/share/opto/predicates.cpp @@ -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);