src/share/vm/opto/loopopts.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7070134 Sdiff src/share/vm/opto

src/share/vm/opto/loopopts.cpp

Print this page




 177       new_loop = get_loop(new_ctrl);
 178     }
 179     // Set new location
 180     set_ctrl(x, new_ctrl);
 181     // If changing loop bodies, see if we need to collect into new body
 182     if (old_loop != new_loop) {
 183       if (old_loop && !old_loop->_child)
 184         old_loop->_body.yank(x);
 185       if (!new_loop->_child)
 186         new_loop->_body.push(x);  // Collect body info
 187     }
 188   }
 189 
 190   return phi;
 191 }
 192 
 193 //------------------------------dominated_by------------------------------------
 194 // Replace the dominated test with an obvious true or false.  Place it on the
 195 // IGVN worklist for later cleanup.  Move control-dependent data Nodes on the
 196 // live path up to the dominating control.
 197 void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip ) {
 198 #ifndef PRODUCT
 199   if (VerifyLoopOptimizations && PrintOpto) tty->print_cr("dominating test");
 200 #endif
 201 
 202 
 203   // prevdom is the dominating projection of the dominating test.
 204   assert( iff->is_If(), "" );
 205   assert( iff->Opcode() == Op_If || iff->Opcode() == Op_CountedLoopEnd, "Check this code when new subtype is added");
 206   int pop = prevdom->Opcode();
 207   assert( pop == Op_IfFalse || pop == Op_IfTrue, "" );
 208   if (flip) {
 209     if (pop == Op_IfTrue)
 210       pop = Op_IfFalse;
 211     else
 212       pop = Op_IfTrue;
 213   }
 214   // 'con' is set to true or false to kill the dominated test.
 215   Node *con = _igvn.makecon(pop == Op_IfTrue ? TypeInt::ONE : TypeInt::ZERO);
 216   set_ctrl(con, C->root()); // Constant gets a new use
 217   // Hack the dominated test
 218   _igvn.hash_delete(iff);
 219   iff->set_req(1, con);
 220   _igvn._worklist.push(iff);
 221 
 222   // If I dont have a reachable TRUE and FALSE path following the IfNode then
 223   // I can assume this path reaches an infinite loop.  In this case it's not
 224   // important to optimize the data Nodes - either the whole compilation will
 225   // be tossed or this path (and all data Nodes) will go dead.
 226   if (iff->outcnt() != 2) return;
 227 
 228   // Make control-dependent data Nodes on the live path (path that will remain
 229   // once the dominated IF is removed) become control-dependent on the
 230   // dominating projection.
 231   Node* dp = ((IfNode*)iff)->proj_out(pop == Op_IfTrue);









 232   IdealLoopTree *old_loop = get_loop(dp);
 233 
 234   for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
 235     Node* cd = dp->fast_out(i); // Control-dependent node
 236     if (cd->depends_only_on_test()) {
 237       assert(cd->in(0) == dp, "");
 238       _igvn.hash_delete(cd);
 239       cd->set_req(0, prevdom);
 240       set_early_ctrl(cd);
 241       _igvn._worklist.push(cd);
 242       IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
 243       if (old_loop != new_loop) {
 244         if (!old_loop->_child) old_loop->_body.yank(cd);
 245         if (!new_loop->_child) new_loop->_body.push(cd);
 246       }
 247       --i;
 248       --imax;
 249     }
 250   }
 251 }


 842   // condition codes input coming from a Phi at the block start.
 843   int n_op = n->Opcode();
 844 
 845   // Check for an IF being dominated by another IF same test
 846   if( n_op == Op_If ) {
 847     Node *bol = n->in(1);
 848     uint max = bol->outcnt();
 849     // Check for same test used more than once?
 850     if( n_op == Op_If && max > 1 && bol->is_Bool() ) {
 851       // Search up IDOMs to see if this IF is dominated.
 852       Node *cutoff = get_ctrl(bol);
 853 
 854       // Now search up IDOMs till cutoff, looking for a dominating test
 855       Node *prevdom = n;
 856       Node *dom = idom(prevdom);
 857       while( dom != cutoff ) {
 858         if( dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom ) {
 859           // Replace the dominated test with an obvious true or false.
 860           // Place it on the IGVN worklist for later cleanup.
 861           C->set_major_progress();
 862           dominated_by( prevdom, n );
 863 #ifndef PRODUCT
 864           if( VerifyLoopOptimizations ) verify();
 865 #endif
 866           return;
 867         }
 868         prevdom = dom;
 869         dom = idom(prevdom);
 870       }
 871     }
 872   }
 873 
 874   // See if a shared loop-varying computation has no loop-varying uses.
 875   // Happens if something is only used for JVM state in uncommon trap exits,
 876   // like various versions of induction variable+offset.  Clone the
 877   // computation per usage to allow it to sink out of the loop.
 878   if (has_ctrl(n) && !n->in(0)) {// n not dead and has no control edge (can float about)
 879     Node *n_ctrl = get_ctrl(n);
 880     IdealLoopTree *n_loop = get_loop(n_ctrl);
 881     if( n_loop != _ltree_root ) {
 882       DUIterator_Fast imax, i = n->fast_outs(imax);




 177       new_loop = get_loop(new_ctrl);
 178     }
 179     // Set new location
 180     set_ctrl(x, new_ctrl);
 181     // If changing loop bodies, see if we need to collect into new body
 182     if (old_loop != new_loop) {
 183       if (old_loop && !old_loop->_child)
 184         old_loop->_body.yank(x);
 185       if (!new_loop->_child)
 186         new_loop->_body.push(x);  // Collect body info
 187     }
 188   }
 189 
 190   return phi;
 191 }
 192 
 193 //------------------------------dominated_by------------------------------------
 194 // Replace the dominated test with an obvious true or false.  Place it on the
 195 // IGVN worklist for later cleanup.  Move control-dependent data Nodes on the
 196 // live path up to the dominating control.
 197 void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exclude_loop_predicate ) {
 198 #ifndef PRODUCT
 199   if (VerifyLoopOptimizations && PrintOpto) tty->print_cr("dominating test");
 200 #endif
 201 
 202 
 203   // prevdom is the dominating projection of the dominating test.
 204   assert( iff->is_If(), "" );
 205   assert( iff->Opcode() == Op_If || iff->Opcode() == Op_CountedLoopEnd, "Check this code when new subtype is added");
 206   int pop = prevdom->Opcode();
 207   assert( pop == Op_IfFalse || pop == Op_IfTrue, "" );
 208   if (flip) {
 209     if (pop == Op_IfTrue)
 210       pop = Op_IfFalse;
 211     else
 212       pop = Op_IfTrue;
 213   }
 214   // 'con' is set to true or false to kill the dominated test.
 215   Node *con = _igvn.makecon(pop == Op_IfTrue ? TypeInt::ONE : TypeInt::ZERO);
 216   set_ctrl(con, C->root()); // Constant gets a new use
 217   // Hack the dominated test
 218   _igvn.hash_delete(iff);
 219   iff->set_req(1, con);
 220   _igvn._worklist.push(iff);
 221 
 222   // If I dont have a reachable TRUE and FALSE path following the IfNode then
 223   // I can assume this path reaches an infinite loop.  In this case it's not
 224   // important to optimize the data Nodes - either the whole compilation will
 225   // be tossed or this path (and all data Nodes) will go dead.
 226   if (iff->outcnt() != 2) return;
 227 
 228   // Make control-dependent data Nodes on the live path (path that will remain
 229   // once the dominated IF is removed) become control-dependent on the
 230   // dominating projection.
 231   Node* dp = iff->as_If()->proj_out(pop == Op_IfTrue);
 232 
 233   // Loop predicates may have depending checks which should not
 234   // be skipped. For example, range check predicate has two checks
 235   // for lower and upper bounds.
 236   ProjNode* unc_proj = iff->as_If()->proj_out(1 - dp->as_Proj()->_con)->as_Proj();
 237   if (exclude_loop_predicate &&
 238       is_uncommon_trap_proj(unc_proj, Deoptimization::Reason_predicate))
 239     return;
 240 
 241   IdealLoopTree *old_loop = get_loop(dp);
 242 
 243   for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
 244     Node* cd = dp->fast_out(i); // Control-dependent node
 245     if (cd->depends_only_on_test()) {
 246       assert(cd->in(0) == dp, "");
 247       _igvn.hash_delete(cd);
 248       cd->set_req(0, prevdom);
 249       set_early_ctrl(cd);
 250       _igvn._worklist.push(cd);
 251       IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
 252       if (old_loop != new_loop) {
 253         if (!old_loop->_child) old_loop->_body.yank(cd);
 254         if (!new_loop->_child) new_loop->_body.push(cd);
 255       }
 256       --i;
 257       --imax;
 258     }
 259   }
 260 }


 851   // condition codes input coming from a Phi at the block start.
 852   int n_op = n->Opcode();
 853 
 854   // Check for an IF being dominated by another IF same test
 855   if( n_op == Op_If ) {
 856     Node *bol = n->in(1);
 857     uint max = bol->outcnt();
 858     // Check for same test used more than once?
 859     if( n_op == Op_If && max > 1 && bol->is_Bool() ) {
 860       // Search up IDOMs to see if this IF is dominated.
 861       Node *cutoff = get_ctrl(bol);
 862 
 863       // Now search up IDOMs till cutoff, looking for a dominating test
 864       Node *prevdom = n;
 865       Node *dom = idom(prevdom);
 866       while( dom != cutoff ) {
 867         if( dom->req() > 1 && dom->in(1) == bol && prevdom->in(0) == dom ) {
 868           // Replace the dominated test with an obvious true or false.
 869           // Place it on the IGVN worklist for later cleanup.
 870           C->set_major_progress();
 871           dominated_by( prevdom, n, false, true );
 872 #ifndef PRODUCT
 873           if( VerifyLoopOptimizations ) verify();
 874 #endif
 875           return;
 876         }
 877         prevdom = dom;
 878         dom = idom(prevdom);
 879       }
 880     }
 881   }
 882 
 883   // See if a shared loop-varying computation has no loop-varying uses.
 884   // Happens if something is only used for JVM state in uncommon trap exits,
 885   // like various versions of induction variable+offset.  Clone the
 886   // computation per usage to allow it to sink out of the loop.
 887   if (has_ctrl(n) && !n->in(0)) {// n not dead and has no control edge (can float about)
 888     Node *n_ctrl = get_ctrl(n);
 889     IdealLoopTree *n_loop = get_loop(n_ctrl);
 890     if( n_loop != _ltree_root ) {
 891       DUIterator_Fast imax, i = n->fast_outs(imax);


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