Mercurial > hg > graal-compiler
comparison src/share/vm/opto/loopnode.cpp @ 6144:5e990493719e
7173340: C2: code cleanup: use PhaseIterGVN::replace_edge(Node*, int, Node*) where applicable
Summary: replace frequent C2 optimizer code patterns with new methods calls
Reviewed-by: kvn, twisti
Contributed-by: vladimir.x.ivanov@oracle.com
author | kvn |
---|---|
date | Tue, 12 Jun 2012 16:23:31 -0700 |
parents | f457154eee8b |
children | 8c92982cbbc4 |
comparison
equal
deleted
inserted
replaced
6143:8b0a4867acf0 | 6144:5e990493719e |
---|---|
1127 // Note that I cannot call 'replace_node' here, because | 1127 // Note that I cannot call 'replace_node' here, because |
1128 // that will yank the edge from old_phi to the Region and | 1128 // that will yank the edge from old_phi to the Region and |
1129 // I'm mid-iteration over the Region's uses. | 1129 // I'm mid-iteration over the Region's uses. |
1130 for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) { | 1130 for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) { |
1131 Node* use = old_phi->last_out(i); | 1131 Node* use = old_phi->last_out(i); |
1132 igvn.hash_delete(use); | 1132 igvn.rehash_node_delayed(use); |
1133 igvn._worklist.push(use); | |
1134 uint uses_found = 0; | 1133 uint uses_found = 0; |
1135 for (uint j = 0; j < use->len(); j++) { | 1134 for (uint j = 0; j < use->len(); j++) { |
1136 if (use->in(j) == old_phi) { | 1135 if (use->in(j) == old_phi) { |
1137 if (j < use->req()) use->set_req (j, id_old_phi); | 1136 if (j < use->req()) use->set_req (j, id_old_phi); |
1138 else use->set_prec(j, id_old_phi); | 1137 else use->set_prec(j, id_old_phi); |
1184 Node *phi = PhiNode::make_blank(outer, old_phi); | 1183 Node *phi = PhiNode::make_blank(outer, old_phi); |
1185 phi->init_req(LoopNode::EntryControl, old_phi->in(LoopNode::EntryControl)); | 1184 phi->init_req(LoopNode::EntryControl, old_phi->in(LoopNode::EntryControl)); |
1186 phi->init_req(LoopNode::LoopBackControl, old_phi->in(outer_idx)); | 1185 phi->init_req(LoopNode::LoopBackControl, old_phi->in(outer_idx)); |
1187 phi = igvn.register_new_node_with_optimizer(phi, old_phi); | 1186 phi = igvn.register_new_node_with_optimizer(phi, old_phi); |
1188 // Make old Phi point to new Phi on the fall-in path | 1187 // Make old Phi point to new Phi on the fall-in path |
1189 igvn.hash_delete(old_phi); | 1188 igvn.replace_input_of(old_phi, LoopNode::EntryControl, phi); |
1190 old_phi->set_req(LoopNode::EntryControl, phi); | |
1191 old_phi->del_req(outer_idx); | 1189 old_phi->del_req(outer_idx); |
1192 igvn._worklist.push(old_phi); | |
1193 } | 1190 } |
1194 } | 1191 } |
1195 | 1192 |
1196 // Use the new loop head instead of the old shared one | 1193 // Use the new loop head instead of the old shared one |
1197 _head = outer; | 1194 _head = outer; |
1990 // As a side effect, Dominators removed any unreachable CFG paths | 1987 // As a side effect, Dominators removed any unreachable CFG paths |
1991 // into RegionNodes. It doesn't do this test against Root, so | 1988 // into RegionNodes. It doesn't do this test against Root, so |
1992 // we do it here. | 1989 // we do it here. |
1993 for( uint i = 1; i < C->root()->req(); i++ ) { | 1990 for( uint i = 1; i < C->root()->req(); i++ ) { |
1994 if( !_nodes[C->root()->in(i)->_idx] ) { // Dead path into Root? | 1991 if( !_nodes[C->root()->in(i)->_idx] ) { // Dead path into Root? |
1995 _igvn.hash_delete(C->root()); | 1992 _igvn.delete_input_of(C->root(), i); |
1996 C->root()->del_req(i); | |
1997 _igvn._worklist.push(C->root()); | |
1998 i--; // Rerun same iteration on compressed edges | 1993 i--; // Rerun same iteration on compressed edges |
1999 } | 1994 } |
2000 } | 1995 } |
2001 | 1996 |
2002 // Given dominators, try to find inner loops with calls that must | 1997 // Given dominators, try to find inner loops with calls that must |