@@ -1858,26 +1858,28 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new,
1858
1858
}
1859
1859
}
1860
1860
1861
- static void clone_outer_loop_helper (Node* n, const IdealLoopTree *loop, const IdealLoopTree* outer_loop,
1862
- const Node_List &old_new, Unique_Node_List& wq, PhaseIdealLoop* phase,
1863
- bool check_old_new) {
1861
+ static void collect_nodes_in_outer_loop_not_reachable_from_sfpt (Node* n, const IdealLoopTree *loop, const IdealLoopTree* outer_loop,
1862
+ const Node_List &old_new, Unique_Node_List& wq, PhaseIdealLoop* phase,
1863
+ bool check_old_new) {
1864
1864
for (DUIterator_Fast jmax, j = n->fast_outs (jmax); j < jmax; j++) {
1865
1865
Node* u = n->fast_out (j);
1866
1866
assert (check_old_new || old_new[u->_idx ] == NULL , " shouldn't have been cloned" );
1867
1867
if (!u->is_CFG () && (!check_old_new || old_new[u->_idx ] == NULL )) {
1868
1868
Node* c = phase->get_ctrl (u);
1869
1869
IdealLoopTree* u_loop = phase->get_loop (c);
1870
- assert (!loop->is_member (u_loop), " can be in outer loop or out of both loops only" );
1871
- if (outer_loop->is_member (u_loop)) {
1872
- wq.push (u);
1873
- } else {
1874
- // nodes pinned with control in the outer loop but not referenced from the safepoint must be moved out of
1875
- // the outer loop too
1876
- Node* u_c = u->in (0 );
1877
- if (u_c != NULL ) {
1878
- IdealLoopTree* u_c_loop = phase->get_loop (u_c);
1879
- if (outer_loop->is_member (u_c_loop) && !loop->is_member (u_c_loop)) {
1880
- wq.push (u);
1870
+ assert (!loop->is_member (u_loop) || !loop->_body .contains (u), " can be in outer loop or out of both loops only" );
1871
+ if (!loop->is_member (u_loop)) {
1872
+ if (outer_loop->is_member (u_loop)) {
1873
+ wq.push (u);
1874
+ } else {
1875
+ // nodes pinned with control in the outer loop but not referenced from the safepoint must be moved out of
1876
+ // the outer loop too
1877
+ Node* u_c = u->in (0 );
1878
+ if (u_c != NULL ) {
1879
+ IdealLoopTree* u_c_loop = phase->get_loop (u_c);
1880
+ if (outer_loop->is_member (u_c_loop) && !loop->is_member (u_c_loop)) {
1881
+ wq.push (u);
1882
+ }
1881
1883
}
1882
1884
}
1883
1885
}
@@ -1996,12 +1998,17 @@ void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealL
1996
1998
Unique_Node_List wq;
1997
1999
for (uint i = 0 ; i < extra_data_nodes.size (); i++) {
1998
2000
Node* old = extra_data_nodes.at (i);
1999
- clone_outer_loop_helper (old, loop, outer_loop, old_new, wq, this , true );
2001
+ collect_nodes_in_outer_loop_not_reachable_from_sfpt (old, loop, outer_loop, old_new, wq, this , true );
2002
+ }
2003
+
2004
+ for (uint i = 0 ; i < loop->_body .size (); i++) {
2005
+ Node* old = loop->_body .at (i);
2006
+ collect_nodes_in_outer_loop_not_reachable_from_sfpt (old, loop, outer_loop, old_new, wq, this , true );
2000
2007
}
2001
2008
2002
2009
Node* inner_out = sfpt->in (0 );
2003
2010
if (inner_out->outcnt () > 1 ) {
2004
- clone_outer_loop_helper (inner_out, loop, outer_loop, old_new, wq, this , true );
2011
+ collect_nodes_in_outer_loop_not_reachable_from_sfpt (inner_out, loop, outer_loop, old_new, wq, this , true );
2005
2012
}
2006
2013
2007
2014
Node* new_ctrl = cl->outer_loop_exit ();
@@ -2012,7 +2019,7 @@ void PhaseIdealLoop::clone_outer_loop(LoopNode* head, CloneLoopMode mode, IdealL
2012
2019
if (n->in (0 ) != NULL ) {
2013
2020
_igvn.replace_input_of (n, 0 , new_ctrl);
2014
2021
}
2015
- clone_outer_loop_helper (n, loop, outer_loop, old_new, wq, this , false );
2022
+ collect_nodes_in_outer_loop_not_reachable_from_sfpt (n, loop, outer_loop, old_new, wq, this , false );
2016
2023
}
2017
2024
} else {
2018
2025
Node *newhead = old_new[loop->_head ->_idx ];
0 commit comments