42 // endif predicate [clone] 43 // stmt4 loop [clone] 44 // endloop stmt1 [clone] 45 // stmt3 46 // stmt4 [clone] 47 // endloop 48 // endif 49 // 50 // Note: the "else" clause may be empty 51 52 //------------------------------policy_unswitching----------------------------- 53 // Return TRUE or FALSE if the loop should be unswitched 54 // (ie. clone loop with an invariant test that does not exit the loop) 55 bool IdealLoopTree::policy_unswitching( PhaseIdealLoop *phase ) const { 56 if( !LoopUnswitching ) { 57 return false; 58 } 59 if (!_head->is_Loop()) { 60 return false; 61 } 62 uint nodes_left = MaxNodeLimit - phase->C->live_nodes(); 63 if (2 * _body.size() > nodes_left) { 64 return false; // Too speculative if running low on nodes. 65 } 66 LoopNode* head = _head->as_Loop(); 67 if (head->unswitch_count() + 1 > head->unswitch_max()) { 68 return false; 69 } 70 return phase->find_unswitching_candidate(this) != NULL; 71 } 72 73 //------------------------------find_unswitching_candidate----------------------------- 74 // Find candidate "if" for unswitching 75 IfNode* PhaseIdealLoop::find_unswitching_candidate(const IdealLoopTree *loop) const { 76 77 // Find first invariant test that doesn't exit the loop 78 LoopNode *head = loop->_head->as_Loop(); 79 IfNode* unswitch_iff = NULL; 80 Node* n = head->in(LoopNode::LoopBackControl); 81 while (n != head) { 82 Node* n_dom = idom(n); 83 if (n->is_Region()) { | 42 // endif predicate [clone] 43 // stmt4 loop [clone] 44 // endloop stmt1 [clone] 45 // stmt3 46 // stmt4 [clone] 47 // endloop 48 // endif 49 // 50 // Note: the "else" clause may be empty 51 52 //------------------------------policy_unswitching----------------------------- 53 // Return TRUE or FALSE if the loop should be unswitched 54 // (ie. clone loop with an invariant test that does not exit the loop) 55 bool IdealLoopTree::policy_unswitching( PhaseIdealLoop *phase ) const { 56 if( !LoopUnswitching ) { 57 return false; 58 } 59 if (!_head->is_Loop()) { 60 return false; 61 } 62 int nodes_left = phase->C->max_node_limit() - phase->C->live_nodes(); 63 if ((int)(2 * _body.size()) > nodes_left) { 64 return false; // Too speculative if running low on nodes. 65 } 66 LoopNode* head = _head->as_Loop(); 67 if (head->unswitch_count() + 1 > head->unswitch_max()) { 68 return false; 69 } 70 return phase->find_unswitching_candidate(this) != NULL; 71 } 72 73 //------------------------------find_unswitching_candidate----------------------------- 74 // Find candidate "if" for unswitching 75 IfNode* PhaseIdealLoop::find_unswitching_candidate(const IdealLoopTree *loop) const { 76 77 // Find first invariant test that doesn't exit the loop 78 LoopNode *head = loop->_head->as_Loop(); 79 IfNode* unswitch_iff = NULL; 80 Node* n = head->in(LoopNode::LoopBackControl); 81 while (n != head) { 82 Node* n_dom = idom(n); 83 if (n->is_Region()) { |