554 j = refresh_out_pos(j); 555 max = outcnt(); 556 } 557 } 558 } 559 } 560 add_to_worklist = true; 561 } 562 } 563 if (add_to_worklist) { 564 phase->is_IterGVN()->add_users_to_worklist(this); // Revisit collapsed Phis 565 } 566 567 if( cnt <= 1 ) { // Only 1 path in? 568 set_req(0, NULL); // Null control input for region copy 569 if( cnt == 0 && !can_reshape) { // Parse phase - leave the node as it is. 570 // No inputs or all inputs are NULL. 571 return NULL; 572 } else if (can_reshape) { // Optimization phase - remove the node 573 PhaseIterGVN *igvn = phase->is_IterGVN(); 574 Node *parent_ctrl; 575 if( cnt == 0 ) { 576 assert( req() == 1, "no inputs expected" ); 577 // During IGVN phase such region will be subsumed by TOP node 578 // so region's phis will have TOP as control node. 579 // Kill phis here to avoid it. PhiNode::is_copy() will be always false. 580 // Also set other user's input to top. 581 parent_ctrl = phase->C->top(); 582 } else { 583 // The fallthrough case since we already checked dead loops above. 584 parent_ctrl = in(1); 585 assert(parent_ctrl != NULL, "Region is a copy of some non-null control"); 586 assert(!igvn->eqv(parent_ctrl, this), "Close dead loop"); 587 } 588 if (!add_to_worklist) 589 igvn->add_users_to_worklist(this); // Check for further allowed opts 590 for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) { 591 Node* n = last_out(i); 592 igvn->hash_delete(n); // Remove from worklist before modifying edges 593 if( n->is_Phi() ) { // Collapse all Phis | 554 j = refresh_out_pos(j); 555 max = outcnt(); 556 } 557 } 558 } 559 } 560 add_to_worklist = true; 561 } 562 } 563 if (add_to_worklist) { 564 phase->is_IterGVN()->add_users_to_worklist(this); // Revisit collapsed Phis 565 } 566 567 if( cnt <= 1 ) { // Only 1 path in? 568 set_req(0, NULL); // Null control input for region copy 569 if( cnt == 0 && !can_reshape) { // Parse phase - leave the node as it is. 570 // No inputs or all inputs are NULL. 571 return NULL; 572 } else if (can_reshape) { // Optimization phase - remove the node 573 PhaseIterGVN *igvn = phase->is_IterGVN(); 574 // Strip mined (inner) loop is going away, remove outer loop. 575 if (is_CountedLoop() && 576 as_Loop()->is_strip_mined()) { 577 Node* outer_sfpt = as_CountedLoop()->outer_safepoint(); 578 Node* outer_out = as_CountedLoop()->outer_loop_exit(); 579 if (outer_sfpt != NULL && outer_out != NULL) { 580 Node* in = outer_sfpt->in(0); 581 igvn->replace_node(outer_out, in); 582 LoopNode* outer = as_CountedLoop()->outer_loop(); 583 igvn->replace_input_of(outer, LoopNode::LoopBackControl, igvn->C->top()); 584 } 585 } 586 Node *parent_ctrl; 587 if( cnt == 0 ) { 588 assert( req() == 1, "no inputs expected" ); 589 // During IGVN phase such region will be subsumed by TOP node 590 // so region's phis will have TOP as control node. 591 // Kill phis here to avoid it. PhiNode::is_copy() will be always false. 592 // Also set other user's input to top. 593 parent_ctrl = phase->C->top(); 594 } else { 595 // The fallthrough case since we already checked dead loops above. 596 parent_ctrl = in(1); 597 assert(parent_ctrl != NULL, "Region is a copy of some non-null control"); 598 assert(!igvn->eqv(parent_ctrl, this), "Close dead loop"); 599 } 600 if (!add_to_worklist) 601 igvn->add_users_to_worklist(this); // Check for further allowed opts 602 for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) { 603 Node* n = last_out(i); 604 igvn->hash_delete(n); // Remove from worklist before modifying edges 605 if( n->is_Phi() ) { // Collapse all Phis |