8223138: Small clean-up in loop-tree support.
Summary: 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
--- a/src/hotspot/share/opto/loopTransform.cpp Wed Apr 17 14:52:25 2019 +0200
+++ b/src/hotspot/share/opto/loopTransform.cpp Thu May 02 11:05:47 2019 +0200
@@ -3249,25 +3249,18 @@
// 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::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;
}
--- a/src/hotspot/share/opto/loopnode.cpp Wed Apr 17 14:52:25 2019 +0200
+++ b/src/hotspot/share/opto/loopnode.cpp Thu May 02 11:05:47 2019 +0200
@@ -2946,7 +2946,7 @@
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;
--- a/src/hotspot/share/opto/loopnode.hpp Wed Apr 17 14:52:25 2019 +0200
+++ b/src/hotspot/share/opto/loopnode.hpp Thu May 02 11:05:47 2019 +0200
@@ -615,9 +615,11 @@
// 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
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;
}