src/hotspot/share/opto/loopnode.cpp
changeset 50623 5209d8a6303e
parent 50525 767cdb97f103
child 50923 c98bf5aa35c5
equal deleted inserted replaced
50622:21b96ce2ed10 50623:5209d8a6303e
  1279     return NULL;
  1279     return NULL;
  1280   }
  1280   }
  1281   return l->outer_safepoint();
  1281   return l->outer_safepoint();
  1282 }
  1282 }
  1283 
  1283 
  1284 Node* CountedLoopNode::skip_predicates() {
  1284 Node* CountedLoopNode::skip_predicates_from_entry(Node* ctrl) {
  1285   if (is_main_loop()) {
       
  1286     Node* ctrl = skip_strip_mined()->in(LoopNode::EntryControl);
       
  1287     while (ctrl != NULL && ctrl->is_Proj() && ctrl->in(0)->is_If() &&
  1285     while (ctrl != NULL && ctrl->is_Proj() && ctrl->in(0)->is_If() &&
  1288            ctrl->in(0)->as_If()->proj_out(1-ctrl->as_Proj()->_con)->outcnt() == 1 &&
  1286            ctrl->in(0)->as_If()->proj_out(1-ctrl->as_Proj()->_con)->outcnt() == 1 &&
  1289            ctrl->in(0)->as_If()->proj_out(1-ctrl->as_Proj()->_con)->unique_out()->Opcode() == Op_Halt) {
  1287            ctrl->in(0)->as_If()->proj_out(1-ctrl->as_Proj()->_con)->unique_out()->Opcode() == Op_Halt) {
  1290       ctrl = ctrl->in(0)->in(0);
  1288       ctrl = ctrl->in(0)->in(0);
  1291     }
  1289     }
  1292 
  1290 
  1293     return ctrl;
  1291     return ctrl;
       
  1292   }
       
  1293 
       
  1294 Node* CountedLoopNode::skip_predicates() {
       
  1295   if (is_main_loop()) {
       
  1296     Node* ctrl = skip_strip_mined()->in(LoopNode::EntryControl);
       
  1297 
       
  1298     return skip_predicates_from_entry(ctrl);
  1294   }
  1299   }
  1295   return in(LoopNode::EntryControl);
  1300   return in(LoopNode::EntryControl);
  1296 }
  1301 }
  1297 
  1302 
  1298 void OuterStripMinedLoopNode::adjust_strip_mined_loop(PhaseIterGVN* igvn) {
  1303 void OuterStripMinedLoopNode::adjust_strip_mined_loop(PhaseIterGVN* igvn) {
  2398   }
  2403   }
  2399   if (UseLoopPredicate) {
  2404   if (UseLoopPredicate) {
  2400     entry = PhaseIdealLoop::find_predicate_insertion_point(entry, Deoptimization::Reason_predicate);
  2405     entry = PhaseIdealLoop::find_predicate_insertion_point(entry, Deoptimization::Reason_predicate);
  2401     if (entry != NULL) {
  2406     if (entry != NULL) {
  2402       tty->print(" predicated");
  2407       tty->print(" predicated");
       
  2408       entry = PhaseIdealLoop::skip_loop_predicates(entry);
       
  2409     }
       
  2410   }
       
  2411   if (UseProfiledLoopPredicate) {
       
  2412     entry = PhaseIdealLoop::find_predicate_insertion_point(entry, Deoptimization::Reason_profile_predicate);
       
  2413     if (entry != NULL) {
       
  2414       tty->print(" profile_predicated");
  2403     }
  2415     }
  2404   }
  2416   }
  2405   if (_head->is_CountedLoop()) {
  2417   if (_head->is_CountedLoop()) {
  2406     CountedLoopNode *cl = _head->as_CountedLoop();
  2418     CountedLoopNode *cl = _head->as_CountedLoop();
  2407     tty->print(" counted");
  2419     tty->print(" counted");
  2505     Node* entry = lpn->in(LoopNode::EntryControl);
  2517     Node* entry = lpn->in(LoopNode::EntryControl);
  2506     Node* predicate_proj = find_predicate(entry); // loop_limit_check first
  2518     Node* predicate_proj = find_predicate(entry); // loop_limit_check first
  2507     if (predicate_proj != NULL ) { // right pattern that can be used by loop predication
  2519     if (predicate_proj != NULL ) { // right pattern that can be used by loop predication
  2508       assert(entry->in(0)->in(1)->in(1)->Opcode() == Op_Opaque1, "must be");
  2520       assert(entry->in(0)->in(1)->in(1)->Opcode() == Op_Opaque1, "must be");
  2509       useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
  2521       useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
  2510       entry = entry->in(0)->in(0);
  2522       entry = skip_loop_predicates(entry);
  2511     }
  2523     }
  2512     predicate_proj = find_predicate(entry); // Predicate
  2524     predicate_proj = find_predicate(entry); // Predicate
  2513     if (predicate_proj != NULL ) {
  2525     if (predicate_proj != NULL ) {
  2514       useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
  2526       useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
       
  2527       entry = skip_loop_predicates(entry);
       
  2528     }
       
  2529     if (UseProfiledLoopPredicate) {
       
  2530       predicate_proj = find_predicate(entry); // Predicate
       
  2531       if (predicate_proj != NULL ) {
       
  2532         useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
       
  2533       }
  2515     }
  2534     }
  2516   }
  2535   }
  2517 
  2536 
  2518   if (loop->_next) { // sibling
  2537   if (loop->_next) { // sibling
  2519     collect_potentially_useful_predicates(loop->_next, useful_predicates);
  2538     collect_potentially_useful_predicates(loop->_next, useful_predicates);
  4203 
  4222 
  4204   // Try not to place code on a loop entry projection
  4223   // Try not to place code on a loop entry projection
  4205   // which can inhibit range check elimination.
  4224   // which can inhibit range check elimination.
  4206   if (least != early) {
  4225   if (least != early) {
  4207     Node* ctrl_out = least->unique_ctrl_out();
  4226     Node* ctrl_out = least->unique_ctrl_out();
  4208     if (ctrl_out && ctrl_out->is_Loop() &&
  4227     if (ctrl_out && ctrl_out->is_CountedLoop() &&
  4209         least == ctrl_out->in(LoopNode::EntryControl) &&
  4228         least == ctrl_out->in(LoopNode::EntryControl)) {
  4210         (ctrl_out->is_CountedLoop() || ctrl_out->is_OuterStripMinedLoop())) {
  4229       Node* new_ctrl = least;
  4211       Node* least_dom = idom(least);
  4230       // Move the node above predicates so a following pass of loop
  4212       if (get_loop(least_dom)->is_member(get_loop(least))) {
  4231       // predication doesn't hoist a predicate that depends on it
  4213         least = least_dom;
  4232       // above that node.
       
  4233       if (find_predicate_insertion_point(new_ctrl, Deoptimization::Reason_loop_limit_check) != NULL) {
       
  4234         new_ctrl = new_ctrl->in(0)->in(0);
       
  4235         assert(is_dominator(early, new_ctrl), "least != early so we can move up the dominator tree");
       
  4236       }
       
  4237       if (find_predicate_insertion_point(new_ctrl, Deoptimization::Reason_profile_predicate) != NULL) {
       
  4238         Node* c = new_ctrl->in(0)->in(0);
       
  4239         assert(is_dominator(early, c), "least != early so we can move up the dominator tree");
       
  4240         new_ctrl = c;
       
  4241       }
       
  4242       if (find_predicate_insertion_point(new_ctrl, Deoptimization::Reason_predicate) != NULL) {
       
  4243         Node* c = new_ctrl->in(0)->in(0);
       
  4244         assert(is_dominator(early, c), "least != early so we can move up the dominator tree");
       
  4245         new_ctrl = c;
       
  4246       }
       
  4247       if (new_ctrl != ctrl_out) {
       
  4248         least = new_ctrl;
       
  4249       } else if (ctrl_out->is_CountedLoop() || ctrl_out->is_OuterStripMinedLoop()) {
       
  4250         Node* least_dom = idom(least);
       
  4251         if (get_loop(least_dom)->is_member(get_loop(least))) {
       
  4252           least = least_dom;
       
  4253         }
  4214       }
  4254       }
  4215     }
  4255     }
  4216   }
  4256   }
  4217 
  4257 
  4218 #ifdef ASSERT
  4258 #ifdef ASSERT