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

Mon, 28 Jun 2010 14:54:39 -0700

author
kvn
date
Mon, 28 Jun 2010 14:54:39 -0700
changeset 1976
6027dddc26c6
parent 1975
d678e3277048
child 1977
76efbe666d6c

6677629: PhaseIterGVN::subsume_node() should call hash_delete() and add_users_to_worklist()
Summary: Use replace_node() method instead of subsume_node().
Reviewed-by: jrose, never

src/share/vm/opto/cfgnode.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/ifnode.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/loopTransform.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/loopnode.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/loopnode.hpp file | annotate | diff | comparison | revisions
src/share/vm/opto/loopopts.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/macro.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/phaseX.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/phaseX.hpp file | annotate | diff | comparison | revisions
src/share/vm/opto/split_if.cpp file | annotate | diff | comparison | revisions
src/share/vm/opto/superword.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/cfgnode.cpp	Mon Jun 28 10:52:50 2010 -0700
     1.2 +++ b/src/share/vm/opto/cfgnode.cpp	Mon Jun 28 14:54:39 2010 -0700
     1.3 @@ -472,9 +472,7 @@
     1.4              assert( n->req() == 2 &&  n->in(1) != NULL, "Only one data input expected" );
     1.5              // Break dead loop data path.
     1.6              // Eagerly replace phis with top to avoid phis copies generation.
     1.7 -            igvn->add_users_to_worklist(n);
     1.8 -            igvn->hash_delete(n); // Yank from hash before hacking edges
     1.9 -            igvn->subsume_node(n, top);
    1.10 +            igvn->replace_node(n, top);
    1.11              if( max != outcnt() ) {
    1.12                progress = true;
    1.13                j = refresh_out_pos(j);
    1.14 @@ -518,18 +516,17 @@
    1.15          igvn->hash_delete(n); // Remove from worklist before modifying edges
    1.16          if( n->is_Phi() ) {   // Collapse all Phis
    1.17            // Eagerly replace phis to avoid copies generation.
    1.18 -          igvn->add_users_to_worklist(n);
    1.19 -          igvn->hash_delete(n); // Yank from hash before hacking edges
    1.20 +          Node* in;
    1.21            if( cnt == 0 ) {
    1.22              assert( n->req() == 1, "No data inputs expected" );
    1.23 -            igvn->subsume_node(n, parent_ctrl); // replaced by top
    1.24 +            in = parent_ctrl; // replaced by top
    1.25            } else {
    1.26              assert( n->req() == 2 &&  n->in(1) != NULL, "Only one data input expected" );
    1.27 -            Node* in1 = n->in(1);               // replaced by unique input
    1.28 -            if( n->as_Phi()->is_unsafe_data_reference(in1) )
    1.29 -              in1 = phase->C->top();            // replaced by top
    1.30 -            igvn->subsume_node(n, in1);
    1.31 +            in = n->in(1);               // replaced by unique input
    1.32 +            if( n->as_Phi()->is_unsafe_data_reference(in) )
    1.33 +              in = phase->C->top();      // replaced by top
    1.34            }
    1.35 +          igvn->replace_node(n, in);
    1.36          }
    1.37          else if( n->is_Region() ) { // Update all incoming edges
    1.38            assert( !igvn->eqv(n, this), "Must be removed from DefUse edges");
    1.39 @@ -2127,7 +2124,7 @@
    1.40      // if it's not there, there's nothing to do.
    1.41      Node* fallthru = proj_out(0);
    1.42      if (fallthru != NULL) {
    1.43 -      phase->is_IterGVN()->subsume_node(fallthru, in(0));
    1.44 +      phase->is_IterGVN()->replace_node(fallthru, in(0));
    1.45      }
    1.46      return phase->C->top();
    1.47    }
     2.1 --- a/src/share/vm/opto/ifnode.cpp	Mon Jun 28 10:52:50 2010 -0700
     2.2 +++ b/src/share/vm/opto/ifnode.cpp	Mon Jun 28 14:54:39 2010 -0700
     2.3 @@ -1081,11 +1081,9 @@
     2.4  
     2.5    igvn->register_new_node_with_optimizer(new_if_f);
     2.6    igvn->register_new_node_with_optimizer(new_if_t);
     2.7 -  igvn->hash_delete(old_if_f);
     2.8 -  igvn->hash_delete(old_if_t);
     2.9    // Flip test, so flip trailing control
    2.10 -  igvn->subsume_node(old_if_f, new_if_t);
    2.11 -  igvn->subsume_node(old_if_t, new_if_f);
    2.12 +  igvn->replace_node(old_if_f, new_if_t);
    2.13 +  igvn->replace_node(old_if_t, new_if_f);
    2.14  
    2.15    // Progress
    2.16    return iff;
     3.1 --- a/src/share/vm/opto/loopTransform.cpp	Mon Jun 28 10:52:50 2010 -0700
     3.2 +++ b/src/share/vm/opto/loopTransform.cpp	Mon Jun 28 14:54:39 2010 -0700
     3.3 @@ -194,8 +194,7 @@
     3.4      addx = new (phase->C, 3) AddINode(x, inv);
     3.5    }
     3.6    phase->register_new_node(addx, phase->get_ctrl(x));
     3.7 -  phase->_igvn.hash_delete(n1);
     3.8 -  phase->_igvn.subsume_node(n1, addx);
     3.9 +  phase->_igvn.replace_node(n1, addx);
    3.10    return addx;
    3.11  }
    3.12  
    3.13 @@ -1586,8 +1585,7 @@
    3.14    Node *phi = cl->phi();
    3.15    Node *final = new (phase->C, 3) SubINode( cl->limit(), cl->stride() );
    3.16    phase->register_new_node(final,cl->in(LoopNode::EntryControl));
    3.17 -  phase->_igvn.hash_delete(phi);
    3.18 -  phase->_igvn.subsume_node(phi,final);
    3.19 +  phase->_igvn.replace_node(phi,final);
    3.20    phase->C->set_major_progress();
    3.21    return true;
    3.22  }
     4.1 --- a/src/share/vm/opto/loopnode.cpp	Mon Jun 28 10:52:50 2010 -0700
     4.2 +++ b/src/share/vm/opto/loopnode.cpp	Mon Jun 28 14:54:39 2010 -0700
     4.3 @@ -400,7 +400,7 @@
     4.4      nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl));
     4.5      nphi = _igvn.register_new_node_with_optimizer(nphi);
     4.6      set_ctrl(nphi, get_ctrl(phi));
     4.7 -    _igvn.subsume_node(phi, nphi);
     4.8 +    _igvn.replace_node(phi, nphi);
     4.9      phi = nphi->as_Phi();
    4.10    }
    4.11    cmp = cmp->clone();
    4.12 @@ -760,7 +760,7 @@
    4.13        // which in turn prevents removing an empty loop.
    4.14        Node *id_old_phi = old_phi->Identity( &igvn );
    4.15        if( id_old_phi != old_phi ) { // Found a simple identity?
    4.16 -        // Note that I cannot call 'subsume_node' here, because
    4.17 +        // Note that I cannot call 'replace_node' here, because
    4.18          // that will yank the edge from old_phi to the Region and
    4.19          // I'm mid-iteration over the Region's uses.
    4.20          for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) {
    4.21 @@ -1065,11 +1065,9 @@
    4.22      l = igvn.register_new_node_with_optimizer(l, _head);
    4.23      phase->set_created_loop_node();
    4.24      // Go ahead and replace _head
    4.25 -    phase->_igvn.subsume_node( _head, l );
    4.26 +    phase->_igvn.replace_node( _head, l );
    4.27      _head = l;
    4.28      phase->set_loop(_head, this);
    4.29 -    for (DUIterator_Fast imax, i = l->fast_outs(imax); i < imax; i++)
    4.30 -      phase->_igvn.add_users_to_worklist(l->fast_out(i));
    4.31    }
    4.32  
    4.33    // Now recursively beautify nested loops
    4.34 @@ -1329,8 +1327,7 @@
    4.35          Node* add  = new (C, 3) AddINode(ratio_idx, diff);
    4.36          phase->_igvn.register_new_node_with_optimizer(add);
    4.37          phase->set_ctrl(add, cl);
    4.38 -        phase->_igvn.hash_delete( phi2 );
    4.39 -        phase->_igvn.subsume_node( phi2, add );
    4.40 +        phase->_igvn.replace_node( phi2, add );
    4.41          // Sometimes an induction variable is unused
    4.42          if (add->outcnt() == 0) {
    4.43            phase->_igvn.remove_dead_node(add);
     5.1 --- a/src/share/vm/opto/loopnode.hpp	Mon Jun 28 10:52:50 2010 -0700
     5.2 +++ b/src/share/vm/opto/loopnode.hpp	Mon Jun 28 14:54:39 2010 -0700
     5.3 @@ -626,8 +626,7 @@
     5.4      _nodes.map( old_node->_idx, (Node*)((intptr_t)new_node + 1) );
     5.5    }
     5.6    void lazy_replace( Node *old_node, Node *new_node ) {
     5.7 -    _igvn.hash_delete(old_node);
     5.8 -    _igvn.subsume_node( old_node, new_node );
     5.9 +    _igvn.replace_node( old_node, new_node );
    5.10      lazy_update( old_node, new_node );
    5.11    }
    5.12    void lazy_replace_proj( Node *old_node, Node *new_node ) {
     6.1 --- a/src/share/vm/opto/loopopts.cpp	Mon Jun 28 10:52:50 2010 -0700
     6.2 +++ b/src/share/vm/opto/loopopts.cpp	Mon Jun 28 14:54:39 2010 -0700
     6.3 @@ -354,8 +354,7 @@
     6.4      register_new_node( var_scale, n_ctrl );
     6.5      Node *var_add = new (C, 3) AddINode( var_scale, inv_scale );
     6.6      register_new_node( var_add, n_ctrl );
     6.7 -    _igvn.hash_delete( n );
     6.8 -    _igvn.subsume_node( n, var_add );
     6.9 +    _igvn.replace_node( n, var_add );
    6.10      return var_add;
    6.11    }
    6.12  
    6.13 @@ -390,8 +389,7 @@
    6.14            register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) );
    6.15            Node *add2 = new (C, 4) AddPNode( n->in(1), add1, n->in(2)->in(3) );
    6.16            register_new_node( add2, n_ctrl );
    6.17 -          _igvn.hash_delete( n );
    6.18 -          _igvn.subsume_node( n, add2 );
    6.19 +          _igvn.replace_node( n, add2 );
    6.20            return add2;
    6.21          }
    6.22        }
    6.23 @@ -412,8 +410,7 @@
    6.24            register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) );
    6.25            Node *add2 = new (C, 4) AddPNode( n->in(1), add1, V );
    6.26            register_new_node( add2, n_ctrl );
    6.27 -          _igvn.hash_delete( n );
    6.28 -          _igvn.subsume_node( n, add2 );
    6.29 +          _igvn.replace_node( n, add2 );
    6.30            return add2;
    6.31          }
    6.32        }
    6.33 @@ -555,8 +552,7 @@
    6.34      }
    6.35      Node *cmov = CMoveNode::make( C, cmov_ctrl, iff->in(1), phi->in(1+flip), phi->in(2-flip), _igvn.type(phi) );
    6.36      register_new_node( cmov, cmov_ctrl );
    6.37 -    _igvn.hash_delete(phi);
    6.38 -    _igvn.subsume_node( phi, cmov );
    6.39 +    _igvn.replace_node( phi, cmov );
    6.40  #ifndef PRODUCT
    6.41      if( VerifyLoopOptimizations ) verify();
    6.42  #endif
    6.43 @@ -642,8 +638,7 @@
    6.44  
    6.45    // Found a Phi to split thru!
    6.46    // Replace 'n' with the new phi
    6.47 -  _igvn.hash_delete(n);
    6.48 -  _igvn.subsume_node( n, phi );
    6.49 +  _igvn.replace_node( n, phi );
    6.50    // Moved a load around the loop, 'en-registering' something.
    6.51    if( n_blk->Opcode() == Op_Loop && n->is_Load() &&
    6.52        !phi->in(LoopNode::LoopBackControl)->is_Load() )
    6.53 @@ -789,13 +784,11 @@
    6.54  
    6.55      // Found a Phi to split thru!
    6.56      // Replace 'n' with the new phi
    6.57 -    _igvn.hash_delete(n);
    6.58 -    _igvn.subsume_node( n, phi );
    6.59 +    _igvn.replace_node( n, phi );
    6.60  
    6.61      // Now split the bool up thru the phi
    6.62      Node *bolphi = split_thru_phi( bol, n_ctrl, -1 );
    6.63 -    _igvn.hash_delete(bol);
    6.64 -    _igvn.subsume_node( bol, bolphi );
    6.65 +    _igvn.replace_node( bol, bolphi );
    6.66      assert( iff->in(1) == bolphi, "" );
    6.67      if( bolphi->Value(&_igvn)->singleton() )
    6.68        return;
    6.69 @@ -803,8 +796,7 @@
    6.70      // Conditional-move?  Must split up now
    6.71      if( !iff->is_If() ) {
    6.72        Node *cmovphi = split_thru_phi( iff, n_ctrl, -1 );
    6.73 -      _igvn.hash_delete(iff);
    6.74 -      _igvn.subsume_node( iff, cmovphi );
    6.75 +      _igvn.replace_node( iff, cmovphi );
    6.76        return;
    6.77      }
    6.78  
    6.79 @@ -950,9 +942,7 @@
    6.80    if( n_op == Op_Opaque2 &&
    6.81        n->in(1) != NULL &&
    6.82        get_loop(get_ctrl(n)) == get_loop(get_ctrl(n->in(1))) ) {
    6.83 -    _igvn.add_users_to_worklist(n);
    6.84 -    _igvn.hash_delete(n);
    6.85 -    _igvn.subsume_node( n, n->in(1) );
    6.86 +    _igvn.replace_node( n, n->in(1) );
    6.87    }
    6.88  }
    6.89  
    6.90 @@ -1425,7 +1415,7 @@
    6.91            // IGVN does CSE).
    6.92            Node *hit = _igvn.hash_find_insert(use);
    6.93            if( hit )             // Go ahead and re-hash for hits.
    6.94 -            _igvn.subsume_node( use, hit );
    6.95 +            _igvn.replace_node( use, hit );
    6.96          }
    6.97  
    6.98          // If 'use' was in the loop-exit block, it now needs to be sunk
     7.1 --- a/src/share/vm/opto/macro.cpp	Mon Jun 28 10:52:50 2010 -0700
     7.2 +++ b/src/share/vm/opto/macro.cpp	Mon Jun 28 14:54:39 2010 -0700
     7.3 @@ -135,8 +135,7 @@
     7.4    if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
     7.5    copy_call_debug_info(oldcall, call);
     7.6    call->set_cnt(PROB_UNLIKELY_MAG(4));  // Same effect as RC_UNCOMMON.
     7.7 -  _igvn.hash_delete(oldcall);
     7.8 -  _igvn.subsume_node(oldcall, call);
     7.9 +  _igvn.replace_node(oldcall, call);
    7.10    transform_later(call);
    7.11  
    7.12    return call;
    7.13 @@ -523,8 +522,7 @@
    7.14          // Kill all new Phis
    7.15          while(value_phis.is_nonempty()) {
    7.16            Node* n = value_phis.node();
    7.17 -          _igvn.hash_delete(n);
    7.18 -          _igvn.subsume_node(n, C->top());
    7.19 +          _igvn.replace_node(n, C->top());
    7.20            value_phis.pop();
    7.21          }
    7.22        }
    7.23 @@ -1311,8 +1309,7 @@
    7.24    if (!always_slow) {
    7.25      call->set_cnt(PROB_UNLIKELY_MAG(4));  // Same effect as RC_UNCOMMON.
    7.26    }
    7.27 -  _igvn.hash_delete(alloc);
    7.28 -  _igvn.subsume_node(alloc, call);
    7.29 +  _igvn.replace_node(alloc, call);
    7.30    transform_later(call);
    7.31  
    7.32    // Identify the output projections from the allocate node and
     8.1 --- a/src/share/vm/opto/phaseX.cpp	Mon Jun 28 10:52:50 2010 -0700
     8.2 +++ b/src/share/vm/opto/phaseX.cpp	Mon Jun 28 14:54:39 2010 -0700
     8.3 @@ -1447,16 +1447,12 @@
     8.4            Node* m = n->out(i);
     8.5            if( m->is_Phi() ) {
     8.6              assert(type(m) == Type::TOP, "Unreachable region should not have live phis.");
     8.7 -            add_users_to_worklist(m);
     8.8 -            hash_delete(m); // Yank from hash before hacking edges
     8.9 -            subsume_node(m, nn);
    8.10 +            replace_node(m, nn);
    8.11              --i; // deleted this phi; rescan starting with next position
    8.12            }
    8.13          }
    8.14        }
    8.15 -      add_users_to_worklist(n); // Users of about-to-be-constant 'n'
    8.16 -      hash_delete(n);           // Removed 'n' from table before subsuming it
    8.17 -      subsume_node(n,nn);       // Update DefUse edges for new constant
    8.18 +      replace_node(n,nn);       // Update DefUse edges for new constant
    8.19      }
    8.20      return nn;
    8.21    }
     9.1 --- a/src/share/vm/opto/phaseX.hpp	Mon Jun 28 10:52:50 2010 -0700
     9.2 +++ b/src/share/vm/opto/phaseX.hpp	Mon Jun 28 14:54:39 2010 -0700
     9.3 @@ -393,6 +393,10 @@
     9.4  
     9.5    // Idealize old Node 'n' with respect to its inputs and its value
     9.6    virtual Node *transform_old( Node *a_node );
     9.7 +
     9.8 +  // Subsume users of node 'old' into node 'nn'
     9.9 +  void subsume_node( Node *old, Node *nn );
    9.10 +
    9.11  protected:
    9.12  
    9.13    // Idealize new Node 'n' with respect to its inputs and its value
    9.14 @@ -439,10 +443,6 @@
    9.15      remove_globally_dead_node(dead);
    9.16    }
    9.17  
    9.18 -  // Subsume users of node 'old' into node 'nn'
    9.19 -  // If no Def-Use info existed for 'nn' it will after call.
    9.20 -  void subsume_node( Node *old, Node *nn );
    9.21 -
    9.22    // Add users of 'n' to worklist
    9.23    void add_users_to_worklist0( Node *n );
    9.24    void add_users_to_worklist ( Node *n );
    9.25 @@ -450,7 +450,7 @@
    9.26    // Replace old node with new one.
    9.27    void replace_node( Node *old, Node *nn ) {
    9.28      add_users_to_worklist(old);
    9.29 -    hash_delete(old);
    9.30 +    hash_delete(old); // Yank from hash before hacking edges
    9.31      subsume_node(old, nn);
    9.32    }
    9.33  
    10.1 --- a/src/share/vm/opto/split_if.cpp	Mon Jun 28 10:52:50 2010 -0700
    10.2 +++ b/src/share/vm/opto/split_if.cpp	Mon Jun 28 14:54:39 2010 -0700
    10.3 @@ -217,8 +217,7 @@
    10.4    register_new_node(phi, blk1);
    10.5  
    10.6    // Remove cloned-up value from optimizer; use phi instead
    10.7 -  _igvn.hash_delete(n);
    10.8 -  _igvn.subsume_node( n, phi );
    10.9 +  _igvn.replace_node( n, phi );
   10.10  
   10.11    // (There used to be a self-recursive call to split_up() here,
   10.12    // but it is not needed.  All necessary forward walking is done
   10.13 @@ -352,8 +351,7 @@
   10.14    }
   10.15  
   10.16    if (use_blk == NULL) {        // He's dead, Jim
   10.17 -    _igvn.hash_delete(use);
   10.18 -    _igvn.subsume_node(use, C->top());
   10.19 +    _igvn.replace_node(use, C->top());
   10.20    }
   10.21  
   10.22    return use_blk;
    11.1 --- a/src/share/vm/opto/superword.cpp	Mon Jun 28 10:52:50 2010 -0700
    11.2 +++ b/src/share/vm/opto/superword.cpp	Mon Jun 28 14:54:39 2010 -0700
    11.3 @@ -1172,8 +1172,7 @@
    11.4        _phase->set_ctrl(vn, _phase->get_ctrl(p->at(0)));
    11.5        for (uint j = 0; j < p->size(); j++) {
    11.6          Node* pm = p->at(j);
    11.7 -        _igvn.hash_delete(pm);
    11.8 -        _igvn.subsume_node(pm, vn);
    11.9 +        _igvn.replace_node(pm, vn);
   11.10        }
   11.11        _igvn._worklist.push(vn);
   11.12      }

mercurial