src/share/vm/opto/loopPredicate.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8034812 Sdiff src/share/vm/opto

src/share/vm/opto/loopPredicate.cpp

Print this page




  87 //                                           uncommon_trap
  88 //
  89 //
  90 // We will create a region to guard the uct call if there is no one there.
  91 // The true projecttion (if_cont) of the new_iff is returned.
  92 // This code is also used to clone predicates to clonned loops.
  93 ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
  94                                                       Deoptimization::DeoptReason reason) {
  95   assert(cont_proj->is_uncommon_trap_if_pattern(reason), "must be a uct if pattern!");
  96   IfNode* iff = cont_proj->in(0)->as_If();
  97 
  98   ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con);
  99   Node     *rgn   = uncommon_proj->unique_ctrl_out();
 100   assert(rgn->is_Region() || rgn->is_Call(), "must be a region or call uct");
 101 
 102   uint proj_index = 1; // region's edge corresponding to uncommon_proj
 103   if (!rgn->is_Region()) { // create a region to guard the call
 104     assert(rgn->is_Call(), "must be call uct");
 105     CallNode* call = rgn->as_Call();
 106     IdealLoopTree* loop = get_loop(call);
 107     rgn = new (C) RegionNode(1);
 108     rgn->add_req(uncommon_proj);
 109     register_control(rgn, loop, uncommon_proj);
 110     _igvn.hash_delete(call);
 111     call->set_req(0, rgn);
 112     // When called from beautify_loops() idom is not constructed yet.
 113     if (_idom != NULL) {
 114       set_idom(call, rgn, dom_depth(rgn));
 115     }
 116   } else {
 117     // Find region's edge corresponding to uncommon_proj
 118     for (; proj_index < rgn->req(); proj_index++)
 119       if (rgn->in(proj_index) == uncommon_proj) break;
 120     assert(proj_index < rgn->req(), "sanity");
 121   }
 122 
 123   Node* entry = iff->in(0);
 124   if (new_entry != NULL) {
 125     // Clonning the predicate to new location.
 126     entry = new_entry;
 127   }
 128   // Create new_iff
 129   IdealLoopTree* lp = get_loop(entry);
 130   IfNode *new_iff = iff->clone()->as_If();
 131   new_iff->set_req(0, entry);
 132   register_control(new_iff, lp, entry);
 133   Node *if_cont = new (C) IfTrueNode(new_iff);
 134   Node *if_uct  = new (C) IfFalseNode(new_iff);
 135   if (cont_proj->is_IfFalse()) {
 136     // Swap
 137     Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp;
 138   }
 139   register_control(if_cont, lp, new_iff);
 140   register_control(if_uct, get_loop(rgn), new_iff);
 141 
 142   // if_uct to rgn
 143   _igvn.hash_delete(rgn);
 144   rgn->add_req(if_uct);
 145   // When called from beautify_loops() idom is not constructed yet.
 146   if (_idom != NULL) {
 147     Node* ridom = idom(rgn);
 148     Node* nrdom = dom_lca(ridom, new_iff);
 149     set_idom(rgn, nrdom, dom_depth(rgn));
 150   }
 151 
 152   // If rgn has phis add new edges which has the same
 153   // value as on original uncommon_proj pass.
 154   assert(rgn->in(rgn->req() -1) == if_uct, "new edge should be last");


 174   }
 175   return if_cont->as_Proj();
 176 }
 177 
 178 //------------------------------create_new_if_for_predicate------------------------
 179 // Create a new if below new_entry for the predicate to be cloned (IGVN optimization)
 180 ProjNode* PhaseIterGVN::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
 181                                                     Deoptimization::DeoptReason reason) {
 182   assert(new_entry != 0, "only used for clone predicate");
 183   assert(cont_proj->is_uncommon_trap_if_pattern(reason), "must be a uct if pattern!");
 184   IfNode* iff = cont_proj->in(0)->as_If();
 185 
 186   ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con);
 187   Node     *rgn   = uncommon_proj->unique_ctrl_out();
 188   assert(rgn->is_Region() || rgn->is_Call(), "must be a region or call uct");
 189 
 190   uint proj_index = 1; // region's edge corresponding to uncommon_proj
 191   if (!rgn->is_Region()) { // create a region to guard the call
 192     assert(rgn->is_Call(), "must be call uct");
 193     CallNode* call = rgn->as_Call();
 194     rgn = new (C) RegionNode(1);
 195     register_new_node_with_optimizer(rgn);
 196     rgn->add_req(uncommon_proj);
 197     hash_delete(call);
 198     call->set_req(0, rgn);
 199   } else {
 200     // Find region's edge corresponding to uncommon_proj
 201     for (; proj_index < rgn->req(); proj_index++)
 202       if (rgn->in(proj_index) == uncommon_proj) break;
 203     assert(proj_index < rgn->req(), "sanity");
 204   }
 205 
 206   // Create new_iff in new location.
 207   IfNode *new_iff = iff->clone()->as_If();
 208   new_iff->set_req(0, new_entry);
 209 
 210   register_new_node_with_optimizer(new_iff);
 211   Node *if_cont = new (C) IfTrueNode(new_iff);
 212   Node *if_uct  = new (C) IfFalseNode(new_iff);
 213   if (cont_proj->is_IfFalse()) {
 214     // Swap
 215     Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp;
 216   }
 217   register_new_node_with_optimizer(if_cont);
 218   register_new_node_with_optimizer(if_uct);
 219 
 220   // if_uct to rgn
 221   hash_delete(rgn);
 222   rgn->add_req(if_uct);
 223 
 224   // If rgn has phis add corresponding new edges which has the same
 225   // value as on original uncommon_proj pass.
 226   assert(rgn->in(rgn->req() -1) == if_uct, "new edge should be last");
 227   bool has_phi = false;
 228   for (DUIterator_Fast imax, i = rgn->fast_outs(imax); i < imax; i++) {
 229     Node* use = rgn->fast_out(i);
 230     if (use->is_Phi() && use->outcnt() > 0) {
 231       rehash_node_delayed(use);
 232       use->add_req(use->in(proj_index));


 237 
 238   return if_cont->as_Proj();
 239 }
 240 
 241 //--------------------------clone_predicate-----------------------
 242 ProjNode* PhaseIdealLoop::clone_predicate(ProjNode* predicate_proj, Node* new_entry,
 243                                           Deoptimization::DeoptReason reason,
 244                                           PhaseIdealLoop* loop_phase,
 245                                           PhaseIterGVN* igvn) {
 246   ProjNode* new_predicate_proj;
 247   if (loop_phase != NULL) {
 248     new_predicate_proj = loop_phase->create_new_if_for_predicate(predicate_proj, new_entry, reason);
 249   } else {
 250     new_predicate_proj =       igvn->create_new_if_for_predicate(predicate_proj, new_entry, reason);
 251   }
 252   IfNode* iff = new_predicate_proj->in(0)->as_If();
 253   Node* ctrl  = iff->in(0);
 254 
 255   // Match original condition since predicate's projections could be swapped.
 256   assert(predicate_proj->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be");
 257   Node* opq = new (igvn->C) Opaque1Node(igvn->C, predicate_proj->in(0)->in(1)->in(1)->in(1));
 258   igvn->C->add_predicate_opaq(opq);
 259 
 260   Node* bol = new (igvn->C) Conv2BNode(opq);
 261   if (loop_phase != NULL) {
 262     loop_phase->register_new_node(opq, ctrl);
 263     loop_phase->register_new_node(bol, ctrl);
 264   } else {
 265     igvn->register_new_node_with_optimizer(opq);
 266     igvn->register_new_node_with_optimizer(bol);
 267   }
 268   igvn->hash_delete(iff);
 269   iff->set_req(1, bol);
 270   return new_predicate_proj;
 271 }
 272 
 273 
 274 //--------------------------clone_loop_predicates-----------------------
 275 // Interface from IGVN
 276 Node* PhaseIterGVN::clone_loop_predicates(Node* old_entry, Node* new_entry, bool clone_limit_check) {
 277   return PhaseIdealLoop::clone_loop_predicates(old_entry, new_entry, clone_limit_check, NULL, this);
 278 }
 279 
 280 // Interface from PhaseIdealLoop


 588 // (2) stride*scale < 0
 589 //   max(scale*i + offset) = scale*init + offset
 590 BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl,
 591                                        int scale, Node* offset,
 592                                        Node* init, Node* limit, Node* stride,
 593                                        Node* range, bool upper) {
 594   stringStream* predString = NULL;
 595   if (TraceLoopPredicate) {
 596     predString = new stringStream();
 597     predString->print("rc_predicate ");
 598   }
 599 
 600   Node* max_idx_expr  = init;
 601   int stride_con = stride->get_int();
 602   if ((stride_con > 0) == (scale > 0) == upper) {
 603     if (LoopLimitCheck) {
 604       // With LoopLimitCheck limit is not exact.
 605       // Calculate exact limit here.
 606       // Note, counted loop's test is '<' or '>'.
 607       limit = exact_limit(loop);
 608       max_idx_expr = new (C) SubINode(limit, stride);
 609       register_new_node(max_idx_expr, ctrl);
 610       if (TraceLoopPredicate) predString->print("(limit - stride) ");
 611     } else {
 612       max_idx_expr = new (C) SubINode(limit, stride);
 613       register_new_node(max_idx_expr, ctrl);
 614       if (TraceLoopPredicate) predString->print("(limit - stride) ");
 615     }
 616   } else {
 617     if (TraceLoopPredicate) predString->print("init ");
 618   }
 619 
 620   if (scale != 1) {
 621     ConNode* con_scale = _igvn.intcon(scale);
 622     max_idx_expr = new (C) MulINode(max_idx_expr, con_scale);
 623     register_new_node(max_idx_expr, ctrl);
 624     if (TraceLoopPredicate) predString->print("* %d ", scale);
 625   }
 626 
 627   if (offset && (!offset->is_Con() || offset->get_int() != 0)){
 628     max_idx_expr = new (C) AddINode(max_idx_expr, offset);
 629     register_new_node(max_idx_expr, ctrl);
 630     if (TraceLoopPredicate)
 631       if (offset->is_Con()) predString->print("+ %d ", offset->get_int());
 632       else predString->print("+ offset ");
 633   }
 634 
 635   CmpUNode* cmp = new (C) CmpUNode(max_idx_expr, range);
 636   register_new_node(cmp, ctrl);
 637   BoolNode* bol = new (C) BoolNode(cmp, BoolTest::lt);
 638   register_new_node(bol, ctrl);
 639 
 640   if (TraceLoopPredicate) {
 641     predString->print_cr("<u range");
 642     tty->print("%s", predString->as_string());
 643   }
 644   return bol;
 645 }
 646 
 647 //------------------------------ loop_predication_impl--------------------------
 648 // Insert loop predicates for null checks and range checks
 649 bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
 650   if (!UseLoopPredicate) return false;
 651 
 652   if (!loop->_head->is_Loop()) {
 653     // Could be a simple region when irreducible loops are present.
 654     return false;
 655   }
 656   LoopNode* head = loop->_head->as_Loop();
 657 


 733         //     does not dominate loop->tail(), so it can not be in the if_proj list.
 734         continue;
 735       }
 736     }
 737 
 738     Node*     test = iff->in(1);
 739     if (!test->is_Bool()){ //Conv2B, ...
 740       continue;
 741     }
 742     BoolNode* bol = test->as_Bool();
 743     if (invar.is_invariant(bol)) {
 744       // Invariant test
 745       new_predicate_proj = create_new_if_for_predicate(predicate_proj, NULL,
 746                                                        Deoptimization::Reason_predicate);
 747       Node* ctrl = new_predicate_proj->in(0)->as_If()->in(0);
 748       BoolNode* new_predicate_bol = invar.clone(bol, ctrl)->as_Bool();
 749 
 750       // Negate test if necessary
 751       bool negated = false;
 752       if (proj->_con != predicate_proj->_con) {
 753         new_predicate_bol = new (C) BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate());
 754         register_new_node(new_predicate_bol, ctrl);
 755         negated = true;
 756       }
 757       IfNode* new_predicate_iff = new_predicate_proj->in(0)->as_If();
 758       _igvn.hash_delete(new_predicate_iff);
 759       new_predicate_iff->set_req(1, new_predicate_bol);
 760 #ifndef PRODUCT
 761       if (TraceLoopPredicate) {
 762         tty->print("Predicate invariant if%s: %d ", negated ? " negated" : "", new_predicate_iff->_idx);
 763         loop->dump_head();
 764       } else if (TraceLoopOpts) {
 765         tty->print("Predicate IC ");
 766         loop->dump_head();
 767       }
 768 #endif
 769     } else if ((cl != NULL) && (proj->_con == predicate_proj->_con) &&
 770                loop->is_range_check_if(iff, this, invar)) {
 771 
 772       // Range check for counted loops
 773       const Node*    cmp    = bol->in(1)->as_Cmp();




  87 //                                           uncommon_trap
  88 //
  89 //
  90 // We will create a region to guard the uct call if there is no one there.
  91 // The true projecttion (if_cont) of the new_iff is returned.
  92 // This code is also used to clone predicates to clonned loops.
  93 ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
  94                                                       Deoptimization::DeoptReason reason) {
  95   assert(cont_proj->is_uncommon_trap_if_pattern(reason), "must be a uct if pattern!");
  96   IfNode* iff = cont_proj->in(0)->as_If();
  97 
  98   ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con);
  99   Node     *rgn   = uncommon_proj->unique_ctrl_out();
 100   assert(rgn->is_Region() || rgn->is_Call(), "must be a region or call uct");
 101 
 102   uint proj_index = 1; // region's edge corresponding to uncommon_proj
 103   if (!rgn->is_Region()) { // create a region to guard the call
 104     assert(rgn->is_Call(), "must be call uct");
 105     CallNode* call = rgn->as_Call();
 106     IdealLoopTree* loop = get_loop(call);
 107     rgn = new RegionNode(1);
 108     rgn->add_req(uncommon_proj);
 109     register_control(rgn, loop, uncommon_proj);
 110     _igvn.hash_delete(call);
 111     call->set_req(0, rgn);
 112     // When called from beautify_loops() idom is not constructed yet.
 113     if (_idom != NULL) {
 114       set_idom(call, rgn, dom_depth(rgn));
 115     }
 116   } else {
 117     // Find region's edge corresponding to uncommon_proj
 118     for (; proj_index < rgn->req(); proj_index++)
 119       if (rgn->in(proj_index) == uncommon_proj) break;
 120     assert(proj_index < rgn->req(), "sanity");
 121   }
 122 
 123   Node* entry = iff->in(0);
 124   if (new_entry != NULL) {
 125     // Clonning the predicate to new location.
 126     entry = new_entry;
 127   }
 128   // Create new_iff
 129   IdealLoopTree* lp = get_loop(entry);
 130   IfNode *new_iff = iff->clone()->as_If();
 131   new_iff->set_req(0, entry);
 132   register_control(new_iff, lp, entry);
 133   Node *if_cont = new IfTrueNode(new_iff);
 134   Node *if_uct  = new IfFalseNode(new_iff);
 135   if (cont_proj->is_IfFalse()) {
 136     // Swap
 137     Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp;
 138   }
 139   register_control(if_cont, lp, new_iff);
 140   register_control(if_uct, get_loop(rgn), new_iff);
 141 
 142   // if_uct to rgn
 143   _igvn.hash_delete(rgn);
 144   rgn->add_req(if_uct);
 145   // When called from beautify_loops() idom is not constructed yet.
 146   if (_idom != NULL) {
 147     Node* ridom = idom(rgn);
 148     Node* nrdom = dom_lca(ridom, new_iff);
 149     set_idom(rgn, nrdom, dom_depth(rgn));
 150   }
 151 
 152   // If rgn has phis add new edges which has the same
 153   // value as on original uncommon_proj pass.
 154   assert(rgn->in(rgn->req() -1) == if_uct, "new edge should be last");


 174   }
 175   return if_cont->as_Proj();
 176 }
 177 
 178 //------------------------------create_new_if_for_predicate------------------------
 179 // Create a new if below new_entry for the predicate to be cloned (IGVN optimization)
 180 ProjNode* PhaseIterGVN::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
 181                                                     Deoptimization::DeoptReason reason) {
 182   assert(new_entry != 0, "only used for clone predicate");
 183   assert(cont_proj->is_uncommon_trap_if_pattern(reason), "must be a uct if pattern!");
 184   IfNode* iff = cont_proj->in(0)->as_If();
 185 
 186   ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con);
 187   Node     *rgn   = uncommon_proj->unique_ctrl_out();
 188   assert(rgn->is_Region() || rgn->is_Call(), "must be a region or call uct");
 189 
 190   uint proj_index = 1; // region's edge corresponding to uncommon_proj
 191   if (!rgn->is_Region()) { // create a region to guard the call
 192     assert(rgn->is_Call(), "must be call uct");
 193     CallNode* call = rgn->as_Call();
 194     rgn = new RegionNode(1);
 195     register_new_node_with_optimizer(rgn);
 196     rgn->add_req(uncommon_proj);
 197     hash_delete(call);
 198     call->set_req(0, rgn);
 199   } else {
 200     // Find region's edge corresponding to uncommon_proj
 201     for (; proj_index < rgn->req(); proj_index++)
 202       if (rgn->in(proj_index) == uncommon_proj) break;
 203     assert(proj_index < rgn->req(), "sanity");
 204   }
 205 
 206   // Create new_iff in new location.
 207   IfNode *new_iff = iff->clone()->as_If();
 208   new_iff->set_req(0, new_entry);
 209 
 210   register_new_node_with_optimizer(new_iff);
 211   Node *if_cont = new IfTrueNode(new_iff);
 212   Node *if_uct  = new IfFalseNode(new_iff);
 213   if (cont_proj->is_IfFalse()) {
 214     // Swap
 215     Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp;
 216   }
 217   register_new_node_with_optimizer(if_cont);
 218   register_new_node_with_optimizer(if_uct);
 219 
 220   // if_uct to rgn
 221   hash_delete(rgn);
 222   rgn->add_req(if_uct);
 223 
 224   // If rgn has phis add corresponding new edges which has the same
 225   // value as on original uncommon_proj pass.
 226   assert(rgn->in(rgn->req() -1) == if_uct, "new edge should be last");
 227   bool has_phi = false;
 228   for (DUIterator_Fast imax, i = rgn->fast_outs(imax); i < imax; i++) {
 229     Node* use = rgn->fast_out(i);
 230     if (use->is_Phi() && use->outcnt() > 0) {
 231       rehash_node_delayed(use);
 232       use->add_req(use->in(proj_index));


 237 
 238   return if_cont->as_Proj();
 239 }
 240 
 241 //--------------------------clone_predicate-----------------------
 242 ProjNode* PhaseIdealLoop::clone_predicate(ProjNode* predicate_proj, Node* new_entry,
 243                                           Deoptimization::DeoptReason reason,
 244                                           PhaseIdealLoop* loop_phase,
 245                                           PhaseIterGVN* igvn) {
 246   ProjNode* new_predicate_proj;
 247   if (loop_phase != NULL) {
 248     new_predicate_proj = loop_phase->create_new_if_for_predicate(predicate_proj, new_entry, reason);
 249   } else {
 250     new_predicate_proj =       igvn->create_new_if_for_predicate(predicate_proj, new_entry, reason);
 251   }
 252   IfNode* iff = new_predicate_proj->in(0)->as_If();
 253   Node* ctrl  = iff->in(0);
 254 
 255   // Match original condition since predicate's projections could be swapped.
 256   assert(predicate_proj->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be");
 257   Node* opq = new Opaque1Node(igvn->C, predicate_proj->in(0)->in(1)->in(1)->in(1));
 258   igvn->C->add_predicate_opaq(opq);
 259 
 260   Node* bol = new Conv2BNode(opq);
 261   if (loop_phase != NULL) {
 262     loop_phase->register_new_node(opq, ctrl);
 263     loop_phase->register_new_node(bol, ctrl);
 264   } else {
 265     igvn->register_new_node_with_optimizer(opq);
 266     igvn->register_new_node_with_optimizer(bol);
 267   }
 268   igvn->hash_delete(iff);
 269   iff->set_req(1, bol);
 270   return new_predicate_proj;
 271 }
 272 
 273 
 274 //--------------------------clone_loop_predicates-----------------------
 275 // Interface from IGVN
 276 Node* PhaseIterGVN::clone_loop_predicates(Node* old_entry, Node* new_entry, bool clone_limit_check) {
 277   return PhaseIdealLoop::clone_loop_predicates(old_entry, new_entry, clone_limit_check, NULL, this);
 278 }
 279 
 280 // Interface from PhaseIdealLoop


 588 // (2) stride*scale < 0
 589 //   max(scale*i + offset) = scale*init + offset
 590 BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl,
 591                                        int scale, Node* offset,
 592                                        Node* init, Node* limit, Node* stride,
 593                                        Node* range, bool upper) {
 594   stringStream* predString = NULL;
 595   if (TraceLoopPredicate) {
 596     predString = new stringStream();
 597     predString->print("rc_predicate ");
 598   }
 599 
 600   Node* max_idx_expr  = init;
 601   int stride_con = stride->get_int();
 602   if ((stride_con > 0) == (scale > 0) == upper) {
 603     if (LoopLimitCheck) {
 604       // With LoopLimitCheck limit is not exact.
 605       // Calculate exact limit here.
 606       // Note, counted loop's test is '<' or '>'.
 607       limit = exact_limit(loop);
 608       max_idx_expr = new SubINode(limit, stride);
 609       register_new_node(max_idx_expr, ctrl);
 610       if (TraceLoopPredicate) predString->print("(limit - stride) ");
 611     } else {
 612       max_idx_expr = new SubINode(limit, stride);
 613       register_new_node(max_idx_expr, ctrl);
 614       if (TraceLoopPredicate) predString->print("(limit - stride) ");
 615     }
 616   } else {
 617     if (TraceLoopPredicate) predString->print("init ");
 618   }
 619 
 620   if (scale != 1) {
 621     ConNode* con_scale = _igvn.intcon(scale);
 622     max_idx_expr = new MulINode(max_idx_expr, con_scale);
 623     register_new_node(max_idx_expr, ctrl);
 624     if (TraceLoopPredicate) predString->print("* %d ", scale);
 625   }
 626 
 627   if (offset && (!offset->is_Con() || offset->get_int() != 0)){
 628     max_idx_expr = new AddINode(max_idx_expr, offset);
 629     register_new_node(max_idx_expr, ctrl);
 630     if (TraceLoopPredicate)
 631       if (offset->is_Con()) predString->print("+ %d ", offset->get_int());
 632       else predString->print("+ offset ");
 633   }
 634 
 635   CmpUNode* cmp = new CmpUNode(max_idx_expr, range);
 636   register_new_node(cmp, ctrl);
 637   BoolNode* bol = new BoolNode(cmp, BoolTest::lt);
 638   register_new_node(bol, ctrl);
 639 
 640   if (TraceLoopPredicate) {
 641     predString->print_cr("<u range");
 642     tty->print("%s", predString->as_string());
 643   }
 644   return bol;
 645 }
 646 
 647 //------------------------------ loop_predication_impl--------------------------
 648 // Insert loop predicates for null checks and range checks
 649 bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
 650   if (!UseLoopPredicate) return false;
 651 
 652   if (!loop->_head->is_Loop()) {
 653     // Could be a simple region when irreducible loops are present.
 654     return false;
 655   }
 656   LoopNode* head = loop->_head->as_Loop();
 657 


 733         //     does not dominate loop->tail(), so it can not be in the if_proj list.
 734         continue;
 735       }
 736     }
 737 
 738     Node*     test = iff->in(1);
 739     if (!test->is_Bool()){ //Conv2B, ...
 740       continue;
 741     }
 742     BoolNode* bol = test->as_Bool();
 743     if (invar.is_invariant(bol)) {
 744       // Invariant test
 745       new_predicate_proj = create_new_if_for_predicate(predicate_proj, NULL,
 746                                                        Deoptimization::Reason_predicate);
 747       Node* ctrl = new_predicate_proj->in(0)->as_If()->in(0);
 748       BoolNode* new_predicate_bol = invar.clone(bol, ctrl)->as_Bool();
 749 
 750       // Negate test if necessary
 751       bool negated = false;
 752       if (proj->_con != predicate_proj->_con) {
 753         new_predicate_bol = new BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate());
 754         register_new_node(new_predicate_bol, ctrl);
 755         negated = true;
 756       }
 757       IfNode* new_predicate_iff = new_predicate_proj->in(0)->as_If();
 758       _igvn.hash_delete(new_predicate_iff);
 759       new_predicate_iff->set_req(1, new_predicate_bol);
 760 #ifndef PRODUCT
 761       if (TraceLoopPredicate) {
 762         tty->print("Predicate invariant if%s: %d ", negated ? " negated" : "", new_predicate_iff->_idx);
 763         loop->dump_head();
 764       } else if (TraceLoopOpts) {
 765         tty->print("Predicate IC ");
 766         loop->dump_head();
 767       }
 768 #endif
 769     } else if ((cl != NULL) && (proj->_con == predicate_proj->_con) &&
 770                loop->is_range_check_if(iff, this, invar)) {
 771 
 772       // Range check for counted loops
 773       const Node*    cmp    = bol->in(1)->as_Cmp();


src/share/vm/opto/loopPredicate.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File