< prev index next >

src/share/vm/opto/loopUnswitch.cpp

Print this page




  44 //    endif                        predicate [clone]
  45 //    stmt4                        loop [clone]
  46 //  endloop                          stmt1 [clone]
  47 //                                   stmt3
  48 //                                   stmt4 [clone]
  49 //                                 endloop
  50 //                               endif
  51 //
  52 // Note: the "else" clause may be empty
  53 
  54 //------------------------------policy_unswitching-----------------------------
  55 // Return TRUE or FALSE if the loop should be unswitched
  56 // (ie. clone loop with an invariant test that does not exit the loop)
  57 bool IdealLoopTree::policy_unswitching( PhaseIdealLoop *phase ) const {
  58   if( !LoopUnswitching ) {
  59     return false;
  60   }
  61   if (!_head->is_Loop()) {
  62     return false;
  63   }






  64   int nodes_left = phase->C->max_node_limit() - phase->C->live_nodes();
  65   if ((int)(2 * _body.size()) > nodes_left) {
  66     return false; // Too speculative if running low on nodes.
  67   }
  68   LoopNode* head = _head->as_Loop();
  69   if (head->unswitch_count() + 1 > head->unswitch_max()) {
  70     return false;
  71   }
  72   return phase->find_unswitching_candidate(this) != NULL;
  73 }
  74 
  75 //------------------------------find_unswitching_candidate-----------------------------
  76 // Find candidate "if" for unswitching
  77 IfNode* PhaseIdealLoop::find_unswitching_candidate(const IdealLoopTree *loop) const {
  78 
  79   // Find first invariant test that doesn't exit the loop
  80   LoopNode *head = loop->_head->as_Loop();
  81   IfNode* unswitch_iff = NULL;
  82   Node* n = head->in(LoopNode::LoopBackControl);
  83   while (n != head) {




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


< prev index next >