< prev index next >
src/hotspot/share/opto/loopopts.cpp
Print this page
@@ -1738,10 +1738,27 @@
sink_use( use, prev );
}
}
}
+static void clone_outer_loop_helper(Node* n, const IdealLoopTree *loop, const IdealLoopTree* outer_loop,
+ const Node_List &old_new, Unique_Node_List& wq, PhaseIdealLoop* phase,
+ bool check_old_new) {
+ for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
+ Node* u = n->fast_out(j);
+ assert(check_old_new || old_new[u->_idx] == NULL, "shouldn't have been cloned");
+ if (!u->is_CFG() && (!check_old_new || old_new[u->_idx] == NULL)) {
+ Node* c = phase->get_ctrl(u);
+ IdealLoopTree* u_loop = phase->get_loop(c);
+ assert(!loop->is_member(u_loop), "can be in outer loop or out of both loops only");
+ if (outer_loop->is_member(u_loop)) {
+ wq.push(u);
+ }
+ }
+ }
+}
+
void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealLoopTree *loop,
IdealLoopTree* outer_loop, int dd, Node_List &old_new,
Node_List& extra_data_nodes) {
if (head->is_strip_mined() && mode != IgnoreStripMined) {
CountedLoopNode* cl = head->as_CountedLoop();
@@ -1842,10 +1859,26 @@
}
if (mode == CloneIncludesStripMined) {
_igvn.register_new_node_with_optimizer(new_sfpt);
_igvn.register_new_node_with_optimizer(new_cle_out);
}
+ // Some other transformation may have pessimistically assign some
+ // data nodes to the outer loop. Set their control so they are out
+ // of the outer loop.
+ ResourceMark rm;
+ Unique_Node_List wq;
+ for (uint i = 0; i < extra_data_nodes.size(); i++) {
+ Node* old = extra_data_nodes.at(i);
+ clone_outer_loop_helper(old, loop, outer_loop, old_new, wq, this, true);
+ }
+ Node* new_ctrl = cl->outer_loop_exit();
+ assert(get_loop(new_ctrl) != outer_loop, "must be out of the loop nest");
+ for (uint i = 0; i < wq.size(); i++) {
+ Node* n = wq.at(i);
+ set_ctrl(n, new_ctrl);
+ clone_outer_loop_helper(n, loop, outer_loop, old_new, wq, this, false);
+ }
} else {
Node *newhead = old_new[loop->_head->_idx];
set_idom(newhead, newhead->in(LoopNode::EntryControl), dd);
}
}
< prev index next >