6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()

Use replace_node() method instead of subsume_node().

Reviewed-by: jrose, never
This commit is contained in:
Vladimir Kozlov 2010-06-28 14:54:39 -07:00
parent 8a416b2365
commit 448b83e288
11 changed files with 40 additions and 71 deletions

View file

@ -472,9 +472,7 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
assert( n->req() == 2 && n->in(1) != NULL, "Only one data input expected" ); assert( n->req() == 2 && n->in(1) != NULL, "Only one data input expected" );
// Break dead loop data path. // Break dead loop data path.
// Eagerly replace phis with top to avoid phis copies generation. // Eagerly replace phis with top to avoid phis copies generation.
igvn->add_users_to_worklist(n); igvn->replace_node(n, top);
igvn->hash_delete(n); // Yank from hash before hacking edges
igvn->subsume_node(n, top);
if( max != outcnt() ) { if( max != outcnt() ) {
progress = true; progress = true;
j = refresh_out_pos(j); j = refresh_out_pos(j);
@ -518,18 +516,17 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) {
igvn->hash_delete(n); // Remove from worklist before modifying edges igvn->hash_delete(n); // Remove from worklist before modifying edges
if( n->is_Phi() ) { // Collapse all Phis if( n->is_Phi() ) { // Collapse all Phis
// Eagerly replace phis to avoid copies generation. // Eagerly replace phis to avoid copies generation.
igvn->add_users_to_worklist(n); Node* in;
igvn->hash_delete(n); // Yank from hash before hacking edges
if( cnt == 0 ) { if( cnt == 0 ) {
assert( n->req() == 1, "No data inputs expected" ); assert( n->req() == 1, "No data inputs expected" );
igvn->subsume_node(n, parent_ctrl); // replaced by top in = parent_ctrl; // replaced by top
} else { } else {
assert( n->req() == 2 && n->in(1) != NULL, "Only one data input expected" ); assert( n->req() == 2 && n->in(1) != NULL, "Only one data input expected" );
Node* in1 = n->in(1); // replaced by unique input in = n->in(1); // replaced by unique input
if( n->as_Phi()->is_unsafe_data_reference(in1) ) if( n->as_Phi()->is_unsafe_data_reference(in) )
in1 = phase->C->top(); // replaced by top in = phase->C->top(); // replaced by top
igvn->subsume_node(n, in1);
} }
igvn->replace_node(n, in);
} }
else if( n->is_Region() ) { // Update all incoming edges else if( n->is_Region() ) { // Update all incoming edges
assert( !igvn->eqv(n, this), "Must be removed from DefUse edges"); assert( !igvn->eqv(n, this), "Must be removed from DefUse edges");
@ -2127,7 +2124,7 @@ Node *NeverBranchNode::Ideal(PhaseGVN *phase, bool can_reshape) {
// if it's not there, there's nothing to do. // if it's not there, there's nothing to do.
Node* fallthru = proj_out(0); Node* fallthru = proj_out(0);
if (fallthru != NULL) { if (fallthru != NULL) {
phase->is_IterGVN()->subsume_node(fallthru, in(0)); phase->is_IterGVN()->replace_node(fallthru, in(0));
} }
return phase->C->top(); return phase->C->top();
} }

View file

@ -1081,11 +1081,9 @@ static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff) {
igvn->register_new_node_with_optimizer(new_if_f); igvn->register_new_node_with_optimizer(new_if_f);
igvn->register_new_node_with_optimizer(new_if_t); igvn->register_new_node_with_optimizer(new_if_t);
igvn->hash_delete(old_if_f);
igvn->hash_delete(old_if_t);
// Flip test, so flip trailing control // Flip test, so flip trailing control
igvn->subsume_node(old_if_f, new_if_t); igvn->replace_node(old_if_f, new_if_t);
igvn->subsume_node(old_if_t, new_if_f); igvn->replace_node(old_if_t, new_if_f);
// Progress // Progress
return iff; return iff;

View file

@ -194,8 +194,7 @@ Node* IdealLoopTree::reassociate_add_sub(Node* n1, PhaseIdealLoop *phase) {
addx = new (phase->C, 3) AddINode(x, inv); addx = new (phase->C, 3) AddINode(x, inv);
} }
phase->register_new_node(addx, phase->get_ctrl(x)); phase->register_new_node(addx, phase->get_ctrl(x));
phase->_igvn.hash_delete(n1); phase->_igvn.replace_node(n1, addx);
phase->_igvn.subsume_node(n1, addx);
return addx; return addx;
} }
@ -1586,8 +1585,7 @@ bool IdealLoopTree::policy_do_remove_empty_loop( PhaseIdealLoop *phase ) {
Node *phi = cl->phi(); Node *phi = cl->phi();
Node *final = new (phase->C, 3) SubINode( cl->limit(), cl->stride() ); Node *final = new (phase->C, 3) SubINode( cl->limit(), cl->stride() );
phase->register_new_node(final,cl->in(LoopNode::EntryControl)); phase->register_new_node(final,cl->in(LoopNode::EntryControl));
phase->_igvn.hash_delete(phi); phase->_igvn.replace_node(phi,final);
phase->_igvn.subsume_node(phi,final);
phase->C->set_major_progress(); phase->C->set_major_progress();
return true; return true;
} }

View file

@ -400,7 +400,7 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl)); nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl));
nphi = _igvn.register_new_node_with_optimizer(nphi); nphi = _igvn.register_new_node_with_optimizer(nphi);
set_ctrl(nphi, get_ctrl(phi)); set_ctrl(nphi, get_ctrl(phi));
_igvn.subsume_node(phi, nphi); _igvn.replace_node(phi, nphi);
phi = nphi->as_Phi(); phi = nphi->as_Phi();
} }
cmp = cmp->clone(); cmp = cmp->clone();
@ -760,7 +760,7 @@ void IdealLoopTree::split_fall_in( PhaseIdealLoop *phase, int fall_in_cnt ) {
// which in turn prevents removing an empty loop. // which in turn prevents removing an empty loop.
Node *id_old_phi = old_phi->Identity( &igvn ); Node *id_old_phi = old_phi->Identity( &igvn );
if( id_old_phi != old_phi ) { // Found a simple identity? if( id_old_phi != old_phi ) { // Found a simple identity?
// Note that I cannot call 'subsume_node' here, because // Note that I cannot call 'replace_node' here, because
// that will yank the edge from old_phi to the Region and // that will yank the edge from old_phi to the Region and
// I'm mid-iteration over the Region's uses. // I'm mid-iteration over the Region's uses.
for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) { for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) {
@ -1065,11 +1065,9 @@ bool IdealLoopTree::beautify_loops( PhaseIdealLoop *phase ) {
l = igvn.register_new_node_with_optimizer(l, _head); l = igvn.register_new_node_with_optimizer(l, _head);
phase->set_created_loop_node(); phase->set_created_loop_node();
// Go ahead and replace _head // Go ahead and replace _head
phase->_igvn.subsume_node( _head, l ); phase->_igvn.replace_node( _head, l );
_head = l; _head = l;
phase->set_loop(_head, this); phase->set_loop(_head, this);
for (DUIterator_Fast imax, i = l->fast_outs(imax); i < imax; i++)
phase->_igvn.add_users_to_worklist(l->fast_out(i));
} }
// Now recursively beautify nested loops // Now recursively beautify nested loops
@ -1329,8 +1327,7 @@ void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
Node* add = new (C, 3) AddINode(ratio_idx, diff); Node* add = new (C, 3) AddINode(ratio_idx, diff);
phase->_igvn.register_new_node_with_optimizer(add); phase->_igvn.register_new_node_with_optimizer(add);
phase->set_ctrl(add, cl); phase->set_ctrl(add, cl);
phase->_igvn.hash_delete( phi2 ); phase->_igvn.replace_node( phi2, add );
phase->_igvn.subsume_node( phi2, add );
// Sometimes an induction variable is unused // Sometimes an induction variable is unused
if (add->outcnt() == 0) { if (add->outcnt() == 0) {
phase->_igvn.remove_dead_node(add); phase->_igvn.remove_dead_node(add);

View file

@ -626,8 +626,7 @@ public:
_nodes.map( old_node->_idx, (Node*)((intptr_t)new_node + 1) ); _nodes.map( old_node->_idx, (Node*)((intptr_t)new_node + 1) );
} }
void lazy_replace( Node *old_node, Node *new_node ) { void lazy_replace( Node *old_node, Node *new_node ) {
_igvn.hash_delete(old_node); _igvn.replace_node( old_node, new_node );
_igvn.subsume_node( old_node, new_node );
lazy_update( old_node, new_node ); lazy_update( old_node, new_node );
} }
void lazy_replace_proj( Node *old_node, Node *new_node ) { void lazy_replace_proj( Node *old_node, Node *new_node ) {

View file

@ -354,8 +354,7 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) {
register_new_node( var_scale, n_ctrl ); register_new_node( var_scale, n_ctrl );
Node *var_add = new (C, 3) AddINode( var_scale, inv_scale ); Node *var_add = new (C, 3) AddINode( var_scale, inv_scale );
register_new_node( var_add, n_ctrl ); register_new_node( var_add, n_ctrl );
_igvn.hash_delete( n ); _igvn.replace_node( n, var_add );
_igvn.subsume_node( n, var_add );
return var_add; return var_add;
} }
@ -390,8 +389,7 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) {
register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) ); register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) );
Node *add2 = new (C, 4) AddPNode( n->in(1), add1, n->in(2)->in(3) ); Node *add2 = new (C, 4) AddPNode( n->in(1), add1, n->in(2)->in(3) );
register_new_node( add2, n_ctrl ); register_new_node( add2, n_ctrl );
_igvn.hash_delete( n ); _igvn.replace_node( n, add2 );
_igvn.subsume_node( n, add2 );
return add2; return add2;
} }
} }
@ -412,8 +410,7 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) {
register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) ); register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) );
Node *add2 = new (C, 4) AddPNode( n->in(1), add1, V ); Node *add2 = new (C, 4) AddPNode( n->in(1), add1, V );
register_new_node( add2, n_ctrl ); register_new_node( add2, n_ctrl );
_igvn.hash_delete( n ); _igvn.replace_node( n, add2 );
_igvn.subsume_node( n, add2 );
return add2; return add2;
} }
} }
@ -555,8 +552,7 @@ Node *PhaseIdealLoop::conditional_move( Node *region ) {
} }
Node *cmov = CMoveNode::make( C, cmov_ctrl, iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi) ); Node *cmov = CMoveNode::make( C, cmov_ctrl, iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi) );
register_new_node( cmov, cmov_ctrl ); register_new_node( cmov, cmov_ctrl );
_igvn.hash_delete(phi); _igvn.replace_node( phi, cmov );
_igvn.subsume_node( phi, cmov );
#ifndef PRODUCT #ifndef PRODUCT
if( VerifyLoopOptimizations ) verify(); if( VerifyLoopOptimizations ) verify();
#endif #endif
@ -642,8 +638,7 @@ Node *PhaseIdealLoop::split_if_with_blocks_pre( Node *n ) {
// Found a Phi to split thru! // Found a Phi to split thru!
// Replace 'n' with the new phi // Replace 'n' with the new phi
_igvn.hash_delete(n); _igvn.replace_node( n, phi );
_igvn.subsume_node( n, phi );
// Moved a load around the loop, 'en-registering' something. // Moved a load around the loop, 'en-registering' something.
if( n_blk->Opcode() == Op_Loop && n->is_Load() && if( n_blk->Opcode() == Op_Loop && n->is_Load() &&
!phi->in(LoopNode::LoopBackControl)->is_Load() ) !phi->in(LoopNode::LoopBackControl)->is_Load() )
@ -789,13 +784,11 @@ void PhaseIdealLoop::split_if_with_blocks_post( Node *n ) {
// Found a Phi to split thru! // Found a Phi to split thru!
// Replace 'n' with the new phi // Replace 'n' with the new phi
_igvn.hash_delete(n); _igvn.replace_node( n, phi );
_igvn.subsume_node( n, phi );
// Now split the bool up thru the phi // Now split the bool up thru the phi
Node *bolphi = split_thru_phi( bol, n_ctrl, -1 ); Node *bolphi = split_thru_phi( bol, n_ctrl, -1 );
_igvn.hash_delete(bol); _igvn.replace_node( bol, bolphi );
_igvn.subsume_node( bol, bolphi );
assert( iff->in(1) == bolphi, "" ); assert( iff->in(1) == bolphi, "" );
if( bolphi->Value(&_igvn)->singleton() ) if( bolphi->Value(&_igvn)->singleton() )
return; return;
@ -803,8 +796,7 @@ void PhaseIdealLoop::split_if_with_blocks_post( Node *n ) {
// Conditional-move? Must split up now // Conditional-move? Must split up now
if( !iff->is_If() ) { if( !iff->is_If() ) {
Node *cmovphi = split_thru_phi( iff, n_ctrl, -1 ); Node *cmovphi = split_thru_phi( iff, n_ctrl, -1 );
_igvn.hash_delete(iff); _igvn.replace_node( iff, cmovphi );
_igvn.subsume_node( iff, cmovphi );
return; return;
} }
@ -950,9 +942,7 @@ void PhaseIdealLoop::split_if_with_blocks_post( Node *n ) {
if( n_op == Op_Opaque2 && if( n_op == Op_Opaque2 &&
n->in(1) != NULL && n->in(1) != NULL &&
get_loop(get_ctrl(n)) == get_loop(get_ctrl(n->in(1))) ) { get_loop(get_ctrl(n)) == get_loop(get_ctrl(n->in(1))) ) {
_igvn.add_users_to_worklist(n); _igvn.replace_node( n, n->in(1) );
_igvn.hash_delete(n);
_igvn.subsume_node( n, n->in(1) );
} }
} }
@ -1425,7 +1415,7 @@ void PhaseIdealLoop::clone_loop( IdealLoopTree *loop, Node_List &old_new, int dd
// IGVN does CSE). // IGVN does CSE).
Node *hit = _igvn.hash_find_insert(use); Node *hit = _igvn.hash_find_insert(use);
if( hit ) // Go ahead and re-hash for hits. if( hit ) // Go ahead and re-hash for hits.
_igvn.subsume_node( use, hit ); _igvn.replace_node( use, hit );
} }
// If 'use' was in the loop-exit block, it now needs to be sunk // If 'use' was in the loop-exit block, it now needs to be sunk

View file

@ -135,8 +135,7 @@ CallNode* PhaseMacroExpand::make_slow_call(CallNode *oldcall, const TypeFunc* sl
if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1);
copy_call_debug_info(oldcall, call); copy_call_debug_info(oldcall, call);
call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON. call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON.
_igvn.hash_delete(oldcall); _igvn.replace_node(oldcall, call);
_igvn.subsume_node(oldcall, call);
transform_later(call); transform_later(call);
return call; return call;
@ -523,8 +522,7 @@ Node *PhaseMacroExpand::value_from_mem(Node *sfpt_mem, BasicType ft, const Type
// Kill all new Phis // Kill all new Phis
while(value_phis.is_nonempty()) { while(value_phis.is_nonempty()) {
Node* n = value_phis.node(); Node* n = value_phis.node();
_igvn.hash_delete(n); _igvn.replace_node(n, C->top());
_igvn.subsume_node(n, C->top());
value_phis.pop(); value_phis.pop();
} }
} }
@ -1311,8 +1309,7 @@ void PhaseMacroExpand::expand_allocate_common(
if (!always_slow) { if (!always_slow) {
call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON. call->set_cnt(PROB_UNLIKELY_MAG(4)); // Same effect as RC_UNCOMMON.
} }
_igvn.hash_delete(alloc); _igvn.replace_node(alloc, call);
_igvn.subsume_node(alloc, call);
transform_later(call); transform_later(call);
// Identify the output projections from the allocate node and // Identify the output projections from the allocate node and

View file

@ -1447,16 +1447,12 @@ Node *PhaseCCP::transform_once( Node *n ) {
Node* m = n->out(i); Node* m = n->out(i);
if( m->is_Phi() ) { if( m->is_Phi() ) {
assert(type(m) == Type::TOP, "Unreachable region should not have live phis."); assert(type(m) == Type::TOP, "Unreachable region should not have live phis.");
add_users_to_worklist(m); replace_node(m, nn);
hash_delete(m); // Yank from hash before hacking edges
subsume_node(m, nn);
--i; // deleted this phi; rescan starting with next position --i; // deleted this phi; rescan starting with next position
} }
} }
} }
add_users_to_worklist(n); // Users of about-to-be-constant 'n' replace_node(n,nn); // Update DefUse edges for new constant
hash_delete(n); // Removed 'n' from table before subsuming it
subsume_node(n,nn); // Update DefUse edges for new constant
} }
return nn; return nn;
} }

View file

@ -393,6 +393,10 @@ class PhaseIterGVN : public PhaseGVN {
// Idealize old Node 'n' with respect to its inputs and its value // Idealize old Node 'n' with respect to its inputs and its value
virtual Node *transform_old( Node *a_node ); virtual Node *transform_old( Node *a_node );
// Subsume users of node 'old' into node 'nn'
void subsume_node( Node *old, Node *nn );
protected: protected:
// Idealize new Node 'n' with respect to its inputs and its value // Idealize new Node 'n' with respect to its inputs and its value
@ -439,10 +443,6 @@ public:
remove_globally_dead_node(dead); remove_globally_dead_node(dead);
} }
// Subsume users of node 'old' into node 'nn'
// If no Def-Use info existed for 'nn' it will after call.
void subsume_node( Node *old, Node *nn );
// Add users of 'n' to worklist // Add users of 'n' to worklist
void add_users_to_worklist0( Node *n ); void add_users_to_worklist0( Node *n );
void add_users_to_worklist ( Node *n ); void add_users_to_worklist ( Node *n );
@ -450,7 +450,7 @@ public:
// Replace old node with new one. // Replace old node with new one.
void replace_node( Node *old, Node *nn ) { void replace_node( Node *old, Node *nn ) {
add_users_to_worklist(old); add_users_to_worklist(old);
hash_delete(old); hash_delete(old); // Yank from hash before hacking edges
subsume_node(old, nn); subsume_node(old, nn);
} }

View file

@ -217,8 +217,7 @@ bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) {
register_new_node(phi, blk1); register_new_node(phi, blk1);
// Remove cloned-up value from optimizer; use phi instead // Remove cloned-up value from optimizer; use phi instead
_igvn.hash_delete(n); _igvn.replace_node( n, phi );
_igvn.subsume_node( n, phi );
// (There used to be a self-recursive call to split_up() here, // (There used to be a self-recursive call to split_up() here,
// but it is not needed. All necessary forward walking is done // but it is not needed. All necessary forward walking is done
@ -352,8 +351,7 @@ Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Nod
} }
if (use_blk == NULL) { // He's dead, Jim if (use_blk == NULL) { // He's dead, Jim
_igvn.hash_delete(use); _igvn.replace_node(use, C->top());
_igvn.subsume_node(use, C->top());
} }
return use_blk; return use_blk;

View file

@ -1172,8 +1172,7 @@ void SuperWord::output() {
_phase->set_ctrl(vn, _phase->get_ctrl(p->at(0))); _phase->set_ctrl(vn, _phase->get_ctrl(p->at(0)));
for (uint j = 0; j < p->size(); j++) { for (uint j = 0; j < p->size(); j++) {
Node* pm = p->at(j); Node* pm = p->at(j);
_igvn.hash_delete(pm); _igvn.replace_node(pm, vn);
_igvn.subsume_node(pm, vn);
} }
_igvn._worklist.push(vn); _igvn._worklist.push(vn);
} }