< prev index next >

src/hotspot/share/opto/split_if.cpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "opto/callnode.hpp"
  28 #include "opto/loopnode.hpp"
  29 #include "opto/movenode.hpp"

  30 
  31 
  32 //------------------------------split_thru_region------------------------------
  33 // Split Node 'n' through merge point.
  34 Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) {
  35   uint wins = 0;
  36   assert( n->is_CFG(), "" );
  37   assert( region->is_Region(), "" );
  38   Node *r = new RegionNode( region->req() );
  39   IdealLoopTree *loop = get_loop( n );
  40   for( uint i = 1; i < region->req(); i++ ) {
  41     Node *x = n->clone();
  42     Node *in0 = n->in(0);
  43     if( in0->in(0) == region ) x->set_req( 0, in0->in(i) );
  44     for( uint j = 1; j < n->req(); j++ ) {
  45       Node *in = n->in(j);
  46       if( get_ctrl(in) == region )
  47         x->set_req( j, in->in(i) );
  48     }
  49     _igvn.register_new_node_with_optimizer(x);


 214         set_ctrl(load,blk1);
 215     }
 216   }
 217 
 218   // Found some other Node; must clone it up
 219 #ifndef PRODUCT
 220   if( PrintOpto && VerifyLoopOptimizations ) {
 221     tty->print("Cloning up: ");
 222     n->dump();
 223   }
 224 #endif
 225 
 226   // ConvI2L may have type information on it which becomes invalid if
 227   // it moves up in the graph so change any clones so widen the type
 228   // to TypeLong::INT when pushing it up.
 229   const Type* rtype = NULL;
 230   if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::INT) {
 231     rtype = TypeLong::INT;
 232   }
 233 









 234   // Now actually split-up this guy.  One copy per control path merging.
 235   Node *phi = PhiNode::make_blank(blk1, n);
 236   for( uint j = 1; j < blk1->req(); j++ ) {
 237     Node *x = n->clone();
 238     // Widen the type of the ConvI2L when pushing up.
 239     if (rtype != NULL) x->as_Type()->set_type(rtype);
 240     if( n->in(0) && n->in(0) == blk1 )
 241       x->set_req( 0, blk1->in(j) );
 242     for( uint i = 1; i < n->req(); i++ ) {
 243       Node *m = n->in(i);
 244       if( get_ctrl(m) == blk1 ) {
 245         assert( m->in(0) == blk1, "" );
 246         x->set_req( i, m->in(j) );
 247       }
 248     }
 249     register_new_node( x, blk1->in(j) );
 250     phi->init_req( j, x );
 251   }
 252   // Announce phi to optimizer
 253   register_new_node(phi, blk1);


 450       Node* n = region->out(i);
 451       if( n == region ) continue;
 452       // The IF to be split is OK.
 453       if( n == iff ) continue;
 454       if( !n->is_Phi() ) {      // Found pinned memory op or such
 455         if (split_up(n, region, iff)) {
 456           i = region->refresh_out_pos(i);
 457           progress = true;
 458         }
 459         continue;
 460       }
 461       assert( n->in(0) == region, "" );
 462 
 463       // Recursively split up all users of a Phi
 464       for (j = n->outs(); n->has_out(j); j++) {
 465         Node* m = n->out(j);
 466         // If m is dead, throw it away, and declare progress
 467         if (_nodes[m->_idx] == NULL) {
 468           _igvn.remove_dead_node(m);
 469           // fall through
 470         }
 471         else if (m != iff && split_up(m, region, iff)) {
 472           // fall through
 473         } else {
 474           continue;
 475         }
 476         // Something unpredictable changed.
 477         // Tell the iterators to refresh themselves, and rerun the loop.
 478         i = region->refresh_out_pos(i);
 479         j = region->refresh_out_pos(j);
 480         progress = true;
 481       }
 482     }
 483   }
 484 
 485   // Now we have no instructions in the block containing the IF.
 486   // Split the IF.
 487   Node *new_iff = split_thru_region( iff, region );
 488 
 489   // Replace both uses of 'new_iff' with Regions merging True/False
 490   // paths.  This makes 'new_iff' go dead.
 491   Node *old_false = NULL, *old_true = NULL;




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "memory/allocation.inline.hpp"
  27 #include "opto/callnode.hpp"
  28 #include "opto/loopnode.hpp"
  29 #include "opto/movenode.hpp"
  30 #include "opto/valuetypenode.hpp"
  31 
  32 
  33 //------------------------------split_thru_region------------------------------
  34 // Split Node 'n' through merge point.
  35 Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) {
  36   uint wins = 0;
  37   assert( n->is_CFG(), "" );
  38   assert( region->is_Region(), "" );
  39   Node *r = new RegionNode( region->req() );
  40   IdealLoopTree *loop = get_loop( n );
  41   for( uint i = 1; i < region->req(); i++ ) {
  42     Node *x = n->clone();
  43     Node *in0 = n->in(0);
  44     if( in0->in(0) == region ) x->set_req( 0, in0->in(i) );
  45     for( uint j = 1; j < n->req(); j++ ) {
  46       Node *in = n->in(j);
  47       if( get_ctrl(in) == region )
  48         x->set_req( j, in->in(i) );
  49     }
  50     _igvn.register_new_node_with_optimizer(x);


 215         set_ctrl(load,blk1);
 216     }
 217   }
 218 
 219   // Found some other Node; must clone it up
 220 #ifndef PRODUCT
 221   if( PrintOpto && VerifyLoopOptimizations ) {
 222     tty->print("Cloning up: ");
 223     n->dump();
 224   }
 225 #endif
 226 
 227   // ConvI2L may have type information on it which becomes invalid if
 228   // it moves up in the graph so change any clones so widen the type
 229   // to TypeLong::INT when pushing it up.
 230   const Type* rtype = NULL;
 231   if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::INT) {
 232     rtype = TypeLong::INT;
 233   }
 234 
 235   // Value types should not be split through Phis but each value input
 236   // needs to be merged individually. At this point, value types should
 237   // only be used by AllocateNodes. Try to remove redundant allocations
 238   // and unlink the now dead value type node.
 239   if (n->is_ValueType()) {
 240     n->as_ValueType()->remove_redundant_allocations(&_igvn, this);
 241     return true; // n is now dead
 242   }
 243 
 244   // Now actually split-up this guy.  One copy per control path merging.
 245   Node *phi = PhiNode::make_blank(blk1, n);
 246   for( uint j = 1; j < blk1->req(); j++ ) {
 247     Node *x = n->clone();
 248     // Widen the type of the ConvI2L when pushing up.
 249     if (rtype != NULL) x->as_Type()->set_type(rtype);
 250     if( n->in(0) && n->in(0) == blk1 )
 251       x->set_req( 0, blk1->in(j) );
 252     for( uint i = 1; i < n->req(); i++ ) {
 253       Node *m = n->in(i);
 254       if( get_ctrl(m) == blk1 ) {
 255         assert( m->in(0) == blk1, "" );
 256         x->set_req( i, m->in(j) );
 257       }
 258     }
 259     register_new_node( x, blk1->in(j) );
 260     phi->init_req( j, x );
 261   }
 262   // Announce phi to optimizer
 263   register_new_node(phi, blk1);


 460       Node* n = region->out(i);
 461       if( n == region ) continue;
 462       // The IF to be split is OK.
 463       if( n == iff ) continue;
 464       if( !n->is_Phi() ) {      // Found pinned memory op or such
 465         if (split_up(n, region, iff)) {
 466           i = region->refresh_out_pos(i);
 467           progress = true;
 468         }
 469         continue;
 470       }
 471       assert( n->in(0) == region, "" );
 472 
 473       // Recursively split up all users of a Phi
 474       for (j = n->outs(); n->has_out(j); j++) {
 475         Node* m = n->out(j);
 476         // If m is dead, throw it away, and declare progress
 477         if (_nodes[m->_idx] == NULL) {
 478           _igvn.remove_dead_node(m);
 479           // fall through
 480         } else if (m != iff && split_up(m, region, iff)) {

 481           // fall through
 482         } else {
 483           continue;
 484         }
 485         // Something unpredictable changed.
 486         // Tell the iterators to refresh themselves, and rerun the loop.
 487         i = region->refresh_out_pos(i);
 488         j = region->refresh_out_pos(j);
 489         progress = true;
 490       }
 491     }
 492   }
 493 
 494   // Now we have no instructions in the block containing the IF.
 495   // Split the IF.
 496   Node *new_iff = split_thru_region( iff, region );
 497 
 498   // Replace both uses of 'new_iff' with Regions merging True/False
 499   // paths.  This makes 'new_iff' go dead.
 500   Node *old_false = NULL, *old_true = NULL;


< prev index next >