comparison src/share/vm/opto/loopnode.cpp @ 1621:6027dddc26c6

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
author kvn
date Mon, 28 Jun 2010 14:54:39 -0700
parents c18cbe5936b8
children d6f45b55c972
comparison
equal deleted inserted replaced
1620:d678e3277048 1621:6027dddc26c6
398 if (!TypeInt::INT->higher_equal(phi->bottom_type())) { 398 if (!TypeInt::INT->higher_equal(phi->bottom_type())) {
399 Node* nphi = PhiNode::make(phi->in(0), phi->in(LoopNode::EntryControl), TypeInt::INT); 399 Node* nphi = PhiNode::make(phi->in(0), phi->in(LoopNode::EntryControl), TypeInt::INT);
400 nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl)); 400 nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl));
401 nphi = _igvn.register_new_node_with_optimizer(nphi); 401 nphi = _igvn.register_new_node_with_optimizer(nphi);
402 set_ctrl(nphi, get_ctrl(phi)); 402 set_ctrl(nphi, get_ctrl(phi));
403 _igvn.subsume_node(phi, nphi); 403 _igvn.replace_node(phi, nphi);
404 phi = nphi->as_Phi(); 404 phi = nphi->as_Phi();
405 } 405 }
406 cmp = cmp->clone(); 406 cmp = cmp->clone();
407 cmp->set_req(1,incr); 407 cmp->set_req(1,incr);
408 cmp->set_req(2,limit); 408 cmp->set_req(2,limit);
758 // disappear it. In JavaGrande I have a case where this useless 758 // disappear it. In JavaGrande I have a case where this useless
759 // Phi is the loop limit and prevents recognizing a CountedLoop 759 // Phi is the loop limit and prevents recognizing a CountedLoop
760 // which in turn prevents removing an empty loop. 760 // which in turn prevents removing an empty loop.
761 Node *id_old_phi = old_phi->Identity( &igvn ); 761 Node *id_old_phi = old_phi->Identity( &igvn );
762 if( id_old_phi != old_phi ) { // Found a simple identity? 762 if( id_old_phi != old_phi ) { // Found a simple identity?
763 // Note that I cannot call 'subsume_node' here, because 763 // Note that I cannot call 'replace_node' here, because
764 // that will yank the edge from old_phi to the Region and 764 // that will yank the edge from old_phi to the Region and
765 // I'm mid-iteration over the Region's uses. 765 // I'm mid-iteration over the Region's uses.
766 for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) { 766 for (DUIterator_Last imin, i = old_phi->last_outs(imin); i >= imin; ) {
767 Node* use = old_phi->last_out(i); 767 Node* use = old_phi->last_out(i);
768 igvn.hash_delete(use); 768 igvn.hash_delete(use);
1063 // Make a new LoopNode to replace the old loop head 1063 // Make a new LoopNode to replace the old loop head
1064 Node *l = new (phase->C, 3) LoopNode( _head->in(1), _head->in(2) ); 1064 Node *l = new (phase->C, 3) LoopNode( _head->in(1), _head->in(2) );
1065 l = igvn.register_new_node_with_optimizer(l, _head); 1065 l = igvn.register_new_node_with_optimizer(l, _head);
1066 phase->set_created_loop_node(); 1066 phase->set_created_loop_node();
1067 // Go ahead and replace _head 1067 // Go ahead and replace _head
1068 phase->_igvn.subsume_node( _head, l ); 1068 phase->_igvn.replace_node( _head, l );
1069 _head = l; 1069 _head = l;
1070 phase->set_loop(_head, this); 1070 phase->set_loop(_head, this);
1071 for (DUIterator_Fast imax, i = l->fast_outs(imax); i < imax; i++)
1072 phase->_igvn.add_users_to_worklist(l->fast_out(i));
1073 } 1071 }
1074 1072
1075 // Now recursively beautify nested loops 1073 // Now recursively beautify nested loops
1076 if( _child ) result |= _child->beautify_loops( phase ); 1074 if( _child ) result |= _child->beautify_loops( phase );
1077 if( _next ) result |= _next ->beautify_loops( phase ); 1075 if( _next ) result |= _next ->beautify_loops( phase );
1327 phase->_igvn.register_new_node_with_optimizer(ratio_idx, phi); 1325 phase->_igvn.register_new_node_with_optimizer(ratio_idx, phi);
1328 phase->set_ctrl(ratio_idx, cl); 1326 phase->set_ctrl(ratio_idx, cl);
1329 Node* add = new (C, 3) AddINode(ratio_idx, diff); 1327 Node* add = new (C, 3) AddINode(ratio_idx, diff);
1330 phase->_igvn.register_new_node_with_optimizer(add); 1328 phase->_igvn.register_new_node_with_optimizer(add);
1331 phase->set_ctrl(add, cl); 1329 phase->set_ctrl(add, cl);
1332 phase->_igvn.hash_delete( phi2 ); 1330 phase->_igvn.replace_node( phi2, add );
1333 phase->_igvn.subsume_node( phi2, add );
1334 // Sometimes an induction variable is unused 1331 // Sometimes an induction variable is unused
1335 if (add->outcnt() == 0) { 1332 if (add->outcnt() == 0) {
1336 phase->_igvn.remove_dead_node(add); 1333 phase->_igvn.remove_dead_node(add);
1337 } 1334 }
1338 --i; // deleted this phi; rescan starting with next position 1335 --i; // deleted this phi; rescan starting with next position