src/share/vm/opto/loopopts.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/loopopts.cpp

Print this page
rev 9094 : 8136926: phi == NULL assert in PhaseIdealLoop::try_move_store_after_loop
Summary: multiple phis on same slice are possible in a loop
Reviewed-by:


 758     IdealLoopTree *n_loop = get_loop(n_ctrl);
 759     // Store must be in a loop
 760     if (n_loop != _ltree_root && !n_loop->_irreducible) {
 761       Node* address = n->in(MemNode::Address);
 762       Node* value = n->in(MemNode::ValueIn);
 763       IdealLoopTree* address_loop = get_loop(get_ctrl(address));
 764       // address must be loop invariant
 765       if (!n_loop->is_member(address_loop)) {
 766         // Store must be last on this memory slice in the loop and
 767         // nothing in the loop must observe it
 768         Node* phi = NULL;
 769         for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
 770           Node* u = n->fast_out(i);
 771           if (has_ctrl(u)) { // control use?
 772             IdealLoopTree *u_loop = get_loop(get_ctrl(u));
 773             if (!n_loop->is_member(u_loop)) {
 774               continue;
 775             }
 776             if (u->is_Phi() && u->in(0) == n_loop->_head) {
 777               assert(_igvn.type(u) == Type::MEMORY, "bad phi");
 778               assert(phi == NULL, "already found");



 779               phi = u;
 780               continue;
 781             }
 782           }
 783           phi = NULL;
 784           break;
 785         }
 786         if (phi != NULL) {
 787           // Nothing in the loop before the store (next iteration)
 788           // must observe the stored value
 789           bool mem_ok = true;
 790           {
 791             ResourceMark rm;
 792             Unique_Node_List wq;
 793             wq.push(phi);
 794             for (uint next = 0; next < wq.size() && mem_ok; ++next) {
 795               Node *m = wq.at(next);
 796               for (DUIterator_Fast imax, i = m->fast_outs(imax); i < imax && mem_ok; i++) {
 797                 Node* u = m->fast_out(i);
 798                 if (u->is_Store() || u->is_Phi()) {
 799                   if (u != n) {
 800                     wq.push(u);
 801                     mem_ok = (wq.size() <= 10);
 802                   }
 803                 } else {
 804                   mem_ok = false;




 758     IdealLoopTree *n_loop = get_loop(n_ctrl);
 759     // Store must be in a loop
 760     if (n_loop != _ltree_root && !n_loop->_irreducible) {
 761       Node* address = n->in(MemNode::Address);
 762       Node* value = n->in(MemNode::ValueIn);
 763       IdealLoopTree* address_loop = get_loop(get_ctrl(address));
 764       // address must be loop invariant
 765       if (!n_loop->is_member(address_loop)) {
 766         // Store must be last on this memory slice in the loop and
 767         // nothing in the loop must observe it
 768         Node* phi = NULL;
 769         for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) {
 770           Node* u = n->fast_out(i);
 771           if (has_ctrl(u)) { // control use?
 772             IdealLoopTree *u_loop = get_loop(get_ctrl(u));
 773             if (!n_loop->is_member(u_loop)) {
 774               continue;
 775             }
 776             if (u->is_Phi() && u->in(0) == n_loop->_head) {
 777               assert(_igvn.type(u) == Type::MEMORY, "bad phi");
 778               // multiple phis on the same slice are possible
 779               if (phi != NULL) {
 780                 return;
 781               }
 782               phi = u;
 783               continue;
 784             }
 785           }
 786           return;

 787         }
 788         if (phi != NULL) {
 789           // Nothing in the loop before the store (next iteration)
 790           // must observe the stored value
 791           bool mem_ok = true;
 792           {
 793             ResourceMark rm;
 794             Unique_Node_List wq;
 795             wq.push(phi);
 796             for (uint next = 0; next < wq.size() && mem_ok; ++next) {
 797               Node *m = wq.at(next);
 798               for (DUIterator_Fast imax, i = m->fast_outs(imax); i < imax && mem_ok; i++) {
 799                 Node* u = m->fast_out(i);
 800                 if (u->is_Store() || u->is_Phi()) {
 801                   if (u != n) {
 802                     wq.push(u);
 803                     mem_ok = (wq.size() <= 10);
 804                   }
 805                 } else {
 806                   mem_ok = false;


src/share/vm/opto/loopopts.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File