From 79a5913077e96fc52059106810abcc44e2085bb9 Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Mon, 28 Oct 2024 14:06:47 +0100 Subject: [PATCH] Review Emanuel --- src/hotspot/share/opto/loopTransform.cpp | 14 +++++++------- src/hotspot/share/opto/predicates.cpp | 11 ++++++----- src/hotspot/share/opto/predicates.hpp | 12 ++++++------ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index bd01c754a54cd..c12805b666767 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -815,8 +815,8 @@ void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) { // Step 5: Assertion Predicates initialization if (counted_loop && UseLoopPredicate) { - initialize_assertion_predicates_for_peeled_loop(new_head->as_CountedLoop(), head->as_CountedLoop(), - first_node_index_in_cloned_loop_body, old_new); + initialize_assertion_predicates_for_peeled_loop(new_head->as_CountedLoop(), head->as_CountedLoop(), + first_node_index_in_cloned_loop_body, old_new); } // Now force out all loop-invariant dominating tests. The optimizer @@ -1982,13 +1982,13 @@ void PhaseIdealLoop::create_assertion_predicates_at_loop(CountedLoopNode* source Node* stride = target_loop_head->stride(); LoopNode* target_outer_loop_head = target_loop_head->skip_strip_mined(); Node* target_loop_entry = target_outer_loop_head->in(LoopNode::EntryControl); - AssertionPredicatesForLoop assertion_predicates_for_loop(init, stride, target_loop_entry, this, - _node_in_loop_body); + CreateAssertionPredicatesVisitor create_assertion_predicates_for_loop(init, stride, target_loop_entry, this, + _node_in_loop_body); Node* source_loop_entry = source_loop_head->skip_strip_mined()->in(LoopNode::EntryControl); PredicateIterator predicate_iterator(source_loop_entry); - predicate_iterator.for_each(assertion_predicates_for_loop); - if (assertion_predicates_for_loop.has_created_predicates()) { - IfTrueNode* last_created_predicate_success_proj = assertion_predicates_for_loop.last_created_success_proj(); + predicate_iterator.for_each(create_assertion_predicates_for_loop); + if (create_assertion_predicates_for_loop.has_created_predicates()) { + IfTrueNode* last_created_predicate_success_proj = create_assertion_predicates_for_loop.last_created_success_proj(); _igvn.replace_input_of(target_outer_loop_head, LoopNode::EntryControl, last_created_predicate_success_proj); set_idom(target_outer_loop_head, last_created_predicate_success_proj, dom_depth(target_outer_loop_head)); } diff --git a/src/hotspot/share/opto/predicates.cpp b/src/hotspot/share/opto/predicates.cpp index 768a8b5ea86a1..54a17376f18e4 100644 --- a/src/hotspot/share/opto/predicates.cpp +++ b/src/hotspot/share/opto/predicates.cpp @@ -728,17 +728,18 @@ void Predicates::dump_for_loop(LoopNode* loop_node) { } #endif // NOT PRODUCT -// Keep track of the current Predicate Block by setting '_current_parse_predicate'. -void AssertionPredicatesForLoop::visit(const ParsePredicate& parse_predicate) { +// Keep track of whether we are in the correct Predicate Block where Template Assertion Predicates can be found. +// The PredicateIterator will always start at the loop entry and first visits the Loop Limit Check Predicate Block. +void CreateAssertionPredicatesVisitor::visit(const ParsePredicate& parse_predicate) { Deoptimization::DeoptReason deopt_reason = parse_predicate.head()->deopt_reason(); if (deopt_reason == Deoptimization::Reason_predicate || deopt_reason == Deoptimization::Reason_profile_predicate) { - _current_parse_predicate = parse_predicate.tail(); + _has_hoisted_check_parse_predicates = true; } } -void AssertionPredicatesForLoop::visit(const TemplateAssertionPredicate& template_assertion_predicate) { - if (_current_parse_predicate == nullptr) { +void CreateAssertionPredicatesVisitor::visit(const TemplateAssertionPredicate& template_assertion_predicate) { + if (!_has_hoisted_check_parse_predicates) { // Only process if we are in the correct Predicate Block. return; } diff --git a/src/hotspot/share/opto/predicates.hpp b/src/hotspot/share/opto/predicates.hpp index e1263f33ace47..5eb0cfc9b3578 100644 --- a/src/hotspot/share/opto/predicates.hpp +++ b/src/hotspot/share/opto/predicates.hpp @@ -943,26 +943,26 @@ class NodeInOriginalLoopBody : public NodeInLoopBody { // Visitor to create Initialized Assertion Predicates at a target loop from Template Assertion Predicates from a source // loop. This visitor can be used in combination with a PredicateIterator. -class AssertionPredicatesForLoop : public PredicateVisitor { +class CreateAssertionPredicatesVisitor : public PredicateVisitor { Node* const _init; Node* const _stride; Node* const _old_target_loop_entry; Node* _new_control; PhaseIdealLoop* const _phase; - ParsePredicateSuccessProj* _current_parse_predicate; + bool _has_hoisted_check_parse_predicates; const NodeInLoopBody& _node_in_loop_body; public: - AssertionPredicatesForLoop(Node* init, Node* stride, Node* new_control, PhaseIdealLoop* phase, - const NodeInLoopBody& node_in_loop_body) + CreateAssertionPredicatesVisitor(Node* init, Node* stride, Node* new_control, PhaseIdealLoop* phase, + const NodeInLoopBody& node_in_loop_body) : _init(init), _stride(stride), _old_target_loop_entry(new_control), _new_control(new_control), _phase(phase), - _current_parse_predicate(nullptr), + _has_hoisted_check_parse_predicates(false), _node_in_loop_body(node_in_loop_body) {} - NONCOPYABLE(AssertionPredicatesForLoop); + NONCOPYABLE(CreateAssertionPredicatesVisitor); using PredicateVisitor::visit;