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.

Reviewed-by: vlivanov, neliasso
This commit is contained in:
Patric Hedlin 2019-05-02 11:05:47 +02:00
parent fcbca82247
commit 205085d8d5
3 changed files with 18 additions and 26 deletions

View File

@ -3249,25 +3249,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);
}
@ -3540,7 +3533,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;
}

View File

@ -2946,7 +2946,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;

View File

@ -615,9 +615,11 @@ public:
// 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);
@ -1410,14 +1412,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;
}