< prev index next >

src/hotspot/share/opto/loopopts.cpp

Print this page




 809             ResourceMark rm;
 810             Unique_Node_List wq;
 811             wq.push(phi);
 812             for (uint next = 0; next < wq.size() && mem_ok; ++next) {
 813               Node *m = wq.at(next);
 814               for (DUIterator_Fast imax, i = m->fast_outs(imax); i < imax && mem_ok; i++) {
 815                 Node* u = m->fast_out(i);
 816                 if (u->is_Store() || u->is_Phi()) {
 817                   if (u != n) {
 818                     wq.push(u);
 819                     mem_ok = (wq.size() <= 10);
 820                   }
 821                 } else {
 822                   mem_ok = false;
 823                   break;
 824                 }
 825               }
 826             }
 827           }
 828           if (mem_ok) {
 829             // Move the Store out of the loop creating clones along
 830             // all paths out of the loop that observe the stored value

 831             _igvn.rehash_node_delayed(phi);
 832             int count = phi->replace_edge(n, n->in(MemNode::Memory));
 833             assert(count > 0, "inconsistent phi");
 834             for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
 835               Node* u = n->fast_out(i);
 836               Node* c = get_ctrl(u);
 837 
 838               if (u->is_Phi()) {
 839                 c = u->in(0)->in(u->find_edge(n));
 840               }
 841               IdealLoopTree *u_loop = get_loop(c);
 842               assert (!n_loop->is_member(u_loop), "only the phi should have been a use in the loop");
 843               while(true) {
 844                 Node* next_c = find_non_split_ctrl(idom(c));
 845                 if (n_loop->is_member(get_loop(next_c))) {
 846                   break;
 847                 }
 848                 c = next_c;
 849               }
 850 
 851               Node* st = n->clone();
 852               st->set_req(0, c);
 853               _igvn.register_new_node_with_optimizer(st);
 854 
 855               set_ctrl(st, c);
 856               IdealLoopTree* new_loop = get_loop(c);
 857               assert(new_loop != n_loop, "should be moved out of loop");
 858               if (new_loop->_child == NULL) new_loop->_body.push(st);
 859 
 860               _igvn.replace_input_of(u, u->find_edge(n), st);
 861               --imax;
 862               --i;
 863             }
 864 




 865 
 866             assert(n->outcnt() == 0, "all uses should be gone");
 867             _igvn.replace_input_of(n, MemNode::Memory, C->top());
 868             // Disconnect the phi now. An empty phi can confuse other
 869             // optimizations in this pass of loop opts..
 870             if (phi->in(LoopNode::LoopBackControl) == phi) {
 871               _igvn.replace_node(phi, phi->in(LoopNode::EntryControl));
 872               n_loop->_body.yank(phi);
 873             }
 874           }
 875         }
 876       }
 877     }
 878   }
 879 }
 880 
 881 //------------------------------split_if_with_blocks_pre-----------------------
 882 // Do the real work in a non-recursive function.  Data nodes want to be
 883 // cloned in the pre-order so they can feed each other nicely.
 884 Node *PhaseIdealLoop::split_if_with_blocks_pre( Node *n ) {
 885   // Cloning these guys is unlikely to win
 886   int n_op = n->Opcode();
 887   if( n_op == Op_MergeMem ) return n;




 809             ResourceMark rm;
 810             Unique_Node_List wq;
 811             wq.push(phi);
 812             for (uint next = 0; next < wq.size() && mem_ok; ++next) {
 813               Node *m = wq.at(next);
 814               for (DUIterator_Fast imax, i = m->fast_outs(imax); i < imax && mem_ok; i++) {
 815                 Node* u = m->fast_out(i);
 816                 if (u->is_Store() || u->is_Phi()) {
 817                   if (u != n) {
 818                     wq.push(u);
 819                     mem_ok = (wq.size() <= 10);
 820                   }
 821                 } else {
 822                   mem_ok = false;
 823                   break;
 824                 }
 825               }
 826             }
 827           }
 828           if (mem_ok) {
 829             // Move the store out of the loop if the LCA of all
 830             // users (except for the phi) is outside the loop.
 831             Node* hook = new Node(1);
 832             _igvn.rehash_node_delayed(phi);
 833             int count = phi->replace_edge(n, hook);
 834             assert(count > 0, "inconsistent phi");



 835 
 836             // Compute latest point this store can go
 837             Node* lca = get_late_ctrl(n, get_ctrl(n));
 838             if (n_loop->is_member(get_loop(lca))) {
 839               // LCA is in the loop - bail out
 840               _igvn.replace_node(hook, n);
 841               return;



















 842             }
 843 
 844             // Move store out of the loop
 845             _igvn.replace_node(hook, n->in(MemNode::Memory));
 846             _igvn.replace_input_of(n, 0, lca);
 847             set_ctrl_and_loop(n, lca);
 848 


 849             // Disconnect the phi now. An empty phi can confuse other
 850             // optimizations in this pass of loop opts..
 851             if (phi->in(LoopNode::LoopBackControl) == phi) {
 852               _igvn.replace_node(phi, phi->in(LoopNode::EntryControl));
 853               n_loop->_body.yank(phi);
 854             }
 855           }
 856         }
 857       }
 858     }
 859   }
 860 }
 861 
 862 //------------------------------split_if_with_blocks_pre-----------------------
 863 // Do the real work in a non-recursive function.  Data nodes want to be
 864 // cloned in the pre-order so they can feed each other nicely.
 865 Node *PhaseIdealLoop::split_if_with_blocks_pre( Node *n ) {
 866   // Cloning these guys is unlikely to win
 867   int n_op = n->Opcode();
 868   if( n_op == Op_MergeMem ) return n;


< prev index next >