hotspot/src/share/vm/opto/loopTransform.cpp
changeset 39429 2c9cde29cd3f
parent 39419 cc993a4ab581
child 40031 6cc034201dba
equal deleted inserted replaced
39428:24cb2cb4ae0b 39429:2c9cde29cd3f
   866 
   866 
   867       // Comparing trip+off vs limit
   867       // Comparing trip+off vs limit
   868       Node *bol = iff->in(1);
   868       Node *bol = iff->in(1);
   869       if (bol->req() != 2) continue; // dead constant test
   869       if (bol->req() != 2) continue; // dead constant test
   870       if (!bol->is_Bool()) {
   870       if (!bol->is_Bool()) {
   871         assert(UseLoopPredicate && bol->Opcode() == Op_Conv2B, "predicate check only");
   871         assert(bol->Opcode() == Op_Conv2B, "predicate check only");
   872         continue;
   872         continue;
   873       }
   873       }
   874       if (bol->as_Bool()->_test._test == BoolTest::ne)
   874       if (bol->as_Bool()->_test._test == BoolTest::ne)
   875         continue; // not RC
   875         continue; // not RC
   876 
   876 
  1758       }
  1758       }
  1759     }
  1759     }
  1760   }
  1760   }
  1761 }
  1761 }
  1762 
  1762 
  1763 //------------------------------dominates_backedge---------------------------------
       
  1764 // Returns true if ctrl is executed on every complete iteration
       
  1765 bool IdealLoopTree::dominates_backedge(Node* ctrl) {
       
  1766   assert(ctrl->is_CFG(), "must be control");
       
  1767   Node* backedge = _head->as_Loop()->in(LoopNode::LoopBackControl);
       
  1768   return _phase->dom_lca_internal(ctrl, backedge) == ctrl;
       
  1769 }
       
  1770 
       
  1771 //------------------------------adjust_limit-----------------------------------
  1763 //------------------------------adjust_limit-----------------------------------
  1772 // Helper function for add_constraint().
  1764 // Helper function for add_constraint().
  1773 Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl) {
  1765 Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl) {
  1774   // Compute "I :: (limit-offset)/scale"
  1766   // Compute "I :: (limit-offset)/scale"
  1775   Node *con = new SubINode(rc_limit, offset);
  1767   Node *con = new SubINode(rc_limit, offset);
  2185       // Adjust pre and main loop limits to guard the correct iteration set
  2177       // Adjust pre and main loop limits to guard the correct iteration set
  2186       if( cmp->Opcode() == Op_CmpU ) {// Unsigned compare is really 2 tests
  2178       if( cmp->Opcode() == Op_CmpU ) {// Unsigned compare is really 2 tests
  2187         if( b_test._test == BoolTest::lt ) { // Range checks always use lt
  2179         if( b_test._test == BoolTest::lt ) { // Range checks always use lt
  2188           // The underflow and overflow limits: 0 <= scale*I+offset < limit
  2180           // The underflow and overflow limits: 0 <= scale*I+offset < limit
  2189           add_constraint( stride_con, scale_con, offset, zero, limit, pre_ctrl, &pre_limit, &main_limit );
  2181           add_constraint( stride_con, scale_con, offset, zero, limit, pre_ctrl, &pre_limit, &main_limit );
  2190           if (!conditional_rc) {
  2182           // (0-offset)/scale could be outside of loop iterations range.
  2191             // (0-offset)/scale could be outside of loop iterations range.
  2183           conditional_rc = true;
  2192             conditional_rc = !loop->dominates_backedge(iff);
       
  2193           }
       
  2194         } else {
  2184         } else {
  2195           if (PrintOpto) {
  2185           if (PrintOpto) {
  2196             tty->print_cr("missed RCE opportunity");
  2186             tty->print_cr("missed RCE opportunity");
  2197           }
  2187           }
  2198           continue;             // In release mode, ignore it
  2188           continue;             // In release mode, ignore it
  2219         case BoolTest::lt:
  2209         case BoolTest::lt:
  2220           // The underflow and overflow limits: MIN_INT <= scale*I+offset < limit
  2210           // The underflow and overflow limits: MIN_INT <= scale*I+offset < limit
  2221           // Note: (MIN_INT+1 == -MAX_INT) is used instead of MIN_INT here
  2211           // Note: (MIN_INT+1 == -MAX_INT) is used instead of MIN_INT here
  2222           // to avoid problem with scale == -1: MIN_INT/(-1) == MIN_INT.
  2212           // to avoid problem with scale == -1: MIN_INT/(-1) == MIN_INT.
  2223           add_constraint( stride_con, scale_con, offset, mini, limit, pre_ctrl, &pre_limit, &main_limit );
  2213           add_constraint( stride_con, scale_con, offset, mini, limit, pre_ctrl, &pre_limit, &main_limit );
  2224           if (!conditional_rc) {
  2214           // ((MIN_INT+1)-offset)/scale could be outside of loop iterations range.
  2225             // ((MIN_INT+1)-offset)/scale could be outside of loop iterations range.
  2215           // Note: negative offset is replaced with 0 but (MIN_INT+1)/scale could
  2226             // Note: negative offset is replaced with 0 but (MIN_INT+1)/scale could
  2216           // still be outside of loop range.
  2227             // still be outside of loop range.
  2217           conditional_rc = true;
  2228             conditional_rc = !loop->dominates_backedge(iff);
       
  2229           }
       
  2230           break;
  2218           break;
  2231         default:
  2219         default:
  2232           if (PrintOpto) {
  2220           if (PrintOpto) {
  2233             tty->print_cr("missed RCE opportunity");
  2221             tty->print_cr("missed RCE opportunity");
  2234           }
  2222           }