Skip to content
Permalink
Browse files
8223138: Small clean-up in loop-tree support.
Rename predicate 'is_inner()' to 'is_innermost()' to be accurate. Added 'is_root()' predicate for root parent test in loop-tree. Changed definition of 'is_loop()' to always lazy-read the tail, since it should never be NULL. Cleanup of 'tail()' definition.

Backport-of: 205085d
  • Loading branch information
GoeLin committed Oct 4, 2021
1 parent 3b88f74 commit d86cf10b3425878f58cfdc7dc725905b4d94bf2f
Showing with 18 additions and 26 deletions.
  1. +7 −14 src/hotspot/share/opto/loopTransform.cpp
  2. +1 −1 src/hotspot/share/opto/loopnode.cpp
  3. +10 −11 src/hotspot/share/opto/loopnode.hpp
@@ -3327,25 +3327,18 @@ bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new )
// Clean out prior deadwood
DCE_loop_body();


// Look for loop-exit tests with my 50/50 guesses from the Parsing stage.
// Replace with a 1-in-10 exit guess.
if (_parent /*not the root loop*/ &&
!_irreducible &&
// Also ignore the occasional dead backedge
!tail()->is_top()) {
if (!is_root() && is_loop()) {
adjust_loop_exit_prob(phase);
}

// Gate unrolling, RCE and peeling efforts.
if (!_child && // If not an inner loop, do not split
!_irreducible &&
_allow_optimizations &&
!tail()->is_top()) { // Also ignore the occasional dead backedge
// Unrolling, RCE and peeling efforts, iff innermost loop.
if (_allow_optimizations && is_innermost()) {
if (!_has_call) {
if (!iteration_split_impl(phase, old_new)) {
return false;
}
if (!iteration_split_impl(phase, old_new)) {
return false;
}
} else if (policy_unswitching(phase)) {
phase->do_unswitching(this, old_new);
return false; // need to recalculate idom data
@@ -3619,7 +3612,7 @@ bool PhaseIdealLoop::match_fill_loop(IdealLoopTree* lpt, Node*& store, Node*& st

bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) {
// Only for counted inner loops
if (!lpt->is_counted() || !lpt->is_inner()) {
if (!lpt->is_counted() || !lpt->is_innermost()) {
return false;
}

@@ -3010,7 +3010,7 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) {
IdealLoopTree* lpt = iter.current();
bool is_counted = lpt->is_counted();
if (!is_counted || !lpt->is_inner()) continue;
if (!is_counted || !lpt->is_innermost()) continue;

// check for vectorized loops, any reassociation of invariants was already done
if (is_counted && lpt->_head->as_CountedLoop()->is_unroll_only()) continue;
@@ -618,9 +618,11 @@ class IdealLoopTree : public ResourceObj {
// Put loop body on igvn work list
void record_for_igvn();

bool is_loop() { return !_irreducible && _tail && !_tail->is_top(); }
bool is_inner() { return is_loop() && _child == NULL; }
bool is_counted() { return is_loop() && _head != NULL && _head->is_CountedLoop(); }
bool is_root() { return _parent == NULL; }
// A proper/reducible loop w/o any (occasional) dead back-edge.
bool is_loop() { return !_irreducible && !tail()->is_top(); }
bool is_counted() { return is_loop() && _head->is_CountedLoop(); }
bool is_innermost() { return is_loop() && _child == NULL; }

void remove_main_post_loops(CountedLoopNode *cl, PhaseIdealLoop *phase);

@@ -1416,14 +1418,11 @@ class CountedLoopReserveKit {
};// class CountedLoopReserveKit

inline Node* IdealLoopTree::tail() {
// Handle lazy update of _tail field
Node *n = _tail;
//while( !n->in(0) ) // Skip dead CFG nodes
//n = n->in(1);
if (n->in(0) == NULL)
n = _phase->get_ctrl(n);
_tail = n;
return n;
// Handle lazy update of _tail field.
if (_tail->in(0) == NULL) {
_tail = _phase->get_ctrl(_tail);
}
return _tail;
}

inline Node* IdealLoopTree::head() {

1 comment on commit d86cf10

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on d86cf10 Oct 4, 2021

Please sign in to comment.