1 /*
   2  * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  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);
  51     set_loop(x, loop);
  52     set_idom(x, x->in(0), dom_depth(x->in(0))+1);
  53     r->init_req(i, x);
  54   }
  55 
  56   // Record region
  57   r->set_req(0,region);         // Not a TRUE RegionNode
  58   _igvn.register_new_node_with_optimizer(r);
  59   set_loop(r, loop);
  60   if( !loop->_child )
  61     loop->_body.push(r);
  62   return r;
  63 }
  64 
  65 //------------------------------split_up---------------------------------------
  66 // Split block-local op up through the phis to empty the current block
  67 bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) {
  68   if( n->is_CFG() ) {
  69     assert( n->in(0) != blk1, "Lousy candidate for split-if" );
  70     return false;
  71   }
  72   if( get_ctrl(n) != blk1 && get_ctrl(n) != blk2 )
  73     return false;               // Not block local
  74   if( n->is_Phi() ) return false; // Local PHIs are expected
  75 
  76   // Recursively split-up inputs
  77   for (uint i = 1; i < n->req(); i++) {
  78     if( split_up( n->in(i), blk1, blk2 ) ) {
  79       // Got split recursively and self went dead?
  80       if (n->outcnt() == 0)
  81         _igvn.remove_dead_node(n);
  82       return true;
  83     }
  84   }
  85 
  86   // Check for needing to clone-up a compare.  Can't do that, it forces
  87   // another (nested) split-if transform.  Instead, clone it "down".
  88   if( n->is_Cmp() ) {
  89     assert(get_ctrl(n) == blk2 || get_ctrl(n) == blk1, "must be in block with IF");
  90     // Check for simple Cmp/Bool/CMove which we can clone-up.  Cmp/Bool/CMove
  91     // sequence can have no other users and it must all reside in the split-if
  92     // block.  Non-simple Cmp/Bool/CMove sequences are 'cloned-down' below -
  93     // private, per-use versions of the Cmp and Bool are made.  These sink to
  94     // the CMove block.  If the CMove is in the split-if block, then in the
  95     // next iteration this will become a simple Cmp/Bool/CMove set to clone-up.
  96     Node *bol, *cmov;
  97     if( !(n->outcnt() == 1 && n->unique_out()->is_Bool() &&
  98           (bol = n->unique_out()->as_Bool()) &&
  99           (get_ctrl(bol) == blk1 ||
 100            get_ctrl(bol) == blk2) &&
 101           bol->outcnt() == 1 &&
 102           bol->unique_out()->is_CMove() &&
 103           (cmov = bol->unique_out()->as_CMove()) &&
 104           (get_ctrl(cmov) == blk1 ||
 105            get_ctrl(cmov) == blk2) ) ) {
 106 
 107       // Must clone down
 108 #ifndef PRODUCT
 109       if( PrintOpto && VerifyLoopOptimizations ) {
 110         tty->print("Cloning down: ");
 111         n->dump();
 112       }
 113 #endif
 114       // Clone down any block-local BoolNode uses of this CmpNode
 115       for (DUIterator i = n->outs(); n->has_out(i); i++) {
 116         Node* bol = n->out(i);
 117         assert( bol->is_Bool(), "" );
 118         if (bol->outcnt() == 1) {
 119           Node* use = bol->unique_out();
 120           if (use->Opcode() == Op_Opaque4) {
 121             if (use->outcnt() == 1) {
 122               Node* iff = use->unique_out();
 123               assert(iff->is_If(), "unexpected node type");
 124               Node *use_c = iff->in(0);
 125               if (use_c == blk1 || use_c == blk2) {
 126                 continue;
 127               }
 128             }
 129           } else {
 130             // We might see an Opaque1 from a loop limit check here
 131             assert(use->is_If() || use->is_CMove() || use->Opcode() == Op_Opaque1, "unexpected node type");
 132             Node *use_c = use->is_If() ? use->in(0) : get_ctrl(use);
 133             if (use_c == blk1 || use_c == blk2) {
 134               assert(use->is_CMove(), "unexpected node type");
 135               continue;
 136             }
 137           }
 138         }
 139         if (get_ctrl(bol) == blk1 || get_ctrl(bol) == blk2) {
 140           // Recursively sink any BoolNode
 141 #ifndef PRODUCT
 142           if( PrintOpto && VerifyLoopOptimizations ) {
 143             tty->print("Cloning down: ");
 144             bol->dump();
 145           }
 146 #endif
 147           for (DUIterator j = bol->outs(); bol->has_out(j); j++) {
 148             Node* u = bol->out(j);
 149             // Uses are either IfNodes, CMoves or Opaque4
 150             if (u->Opcode() == Op_Opaque4) {
 151               assert(u->in(1) == bol, "bad input");
 152               for (DUIterator_Last kmin, k = u->last_outs(kmin); k >= kmin; --k) {
 153                 Node* iff = u->last_out(k);
 154                 assert(iff->is_If() || iff->is_CMove(), "unexpected node type");
 155                 assert( iff->in(1) == u, "" );
 156                 // Get control block of either the CMove or the If input
 157                 Node *iff_ctrl = iff->is_If() ? iff->in(0) : get_ctrl(iff);
 158                 Node *x1 = bol->clone();
 159                 Node *x2 = u->clone();
 160                 register_new_node(x1, iff_ctrl);
 161                 register_new_node(x2, iff_ctrl);
 162                 _igvn.replace_input_of(x2, 1, x1);
 163                 _igvn.replace_input_of(iff, 1, x2);
 164               }
 165               _igvn.remove_dead_node(u);
 166               --j;
 167             } else {
 168               // We might see an Opaque1 from a loop limit check here
 169               assert(u->is_If() || u->is_CMove() || u->Opcode() == Op_Opaque1, "unexpected node type");
 170               assert(u->in(1) == bol, "");
 171               // Get control block of either the CMove or the If input
 172               Node *u_ctrl = u->is_If() ? u->in(0) : get_ctrl(u);
 173               assert((u_ctrl != blk1 && u_ctrl != blk2) || u->is_CMove(), "won't converge");
 174               Node *x = bol->clone();
 175               register_new_node(x, u_ctrl);
 176               _igvn.replace_input_of(u, 1, x);
 177               --j;
 178             }
 179           }
 180           _igvn.remove_dead_node(bol);
 181           --i;
 182         }
 183       }
 184       // Clone down this CmpNode
 185       for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin; --j) {
 186         Node* bol = n->last_out(j);
 187         assert( bol->in(1) == n, "" );
 188         Node *x = n->clone();
 189         register_new_node(x, get_ctrl(bol));
 190         _igvn.replace_input_of(bol, 1, x);
 191       }
 192       _igvn.remove_dead_node( n );
 193 
 194       return true;
 195     }
 196   }
 197 
 198   // See if splitting-up a Store.  Any anti-dep loads must go up as
 199   // well.  An anti-dep load might be in the wrong block, because in
 200   // this particular layout/schedule we ignored anti-deps and allow
 201   // memory to be alive twice.  This only works if we do the same
 202   // operations on anti-dep loads as we do their killing stores.
 203   if( n->is_Store() && n->in(MemNode::Memory)->in(0) == n->in(0) ) {
 204     // Get store's memory slice
 205     int alias_idx = C->get_alias_index(_igvn.type(n->in(MemNode::Address))->is_ptr());
 206 
 207     // Get memory-phi anti-dep loads will be using
 208     Node *memphi = n->in(MemNode::Memory);
 209     assert( memphi->is_Phi(), "" );
 210     // Hoist any anti-dep load to the splitting block;
 211     // it will then "split-up".
 212     for (DUIterator_Fast imax,i = memphi->fast_outs(imax); i < imax; i++) {
 213       Node *load = memphi->fast_out(i);
 214       if( load->is_Load() && alias_idx == C->get_alias_index(_igvn.type(load->in(MemNode::Address))->is_ptr()) )
 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);
 264 
 265   // Remove cloned-up value from optimizer; use phi instead
 266   _igvn.replace_node( n, phi );
 267 
 268   // (There used to be a self-recursive call to split_up() here,
 269   // but it is not needed.  All necessary forward walking is done
 270   // by do_split_if() below.)
 271 
 272   return true;
 273 }
 274 
 275 //------------------------------register_new_node------------------------------
 276 void PhaseIdealLoop::register_new_node( Node *n, Node *blk ) {
 277   assert(!n->is_CFG(), "must be data node");
 278   _igvn.register_new_node_with_optimizer(n);
 279   set_ctrl(n, blk);
 280   IdealLoopTree *loop = get_loop(blk);
 281   if( !loop->_child )
 282     loop->_body.push(n);
 283 }
 284 
 285 //------------------------------small_cache------------------------------------
 286 struct small_cache : public Dict {
 287 
 288   small_cache() : Dict( cmpkey, hashptr ) {}
 289   Node *probe( Node *use_blk ) { return (Node*)((*this)[use_blk]); }
 290   void lru_insert( Node *use_blk, Node *new_def ) { Insert(use_blk,new_def); }
 291 };
 292 
 293 //------------------------------spinup-----------------------------------------
 294 // "Spin up" the dominator tree, starting at the use site and stopping when we
 295 // find the post-dominating point.
 296 
 297 // We must be at the merge point which post-dominates 'new_false' and
 298 // 'new_true'.  Figure out which edges into the RegionNode eventually lead up
 299 // to false and which to true.  Put in a PhiNode to merge values; plug in
 300 // the appropriate false-arm or true-arm values.  If some path leads to the
 301 // original IF, then insert a Phi recursively.
 302 Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, Node *use_blk, Node *def, small_cache *cache ) {
 303   if (use_blk->is_top())        // Handle dead uses
 304     return use_blk;
 305   Node *prior_n = (Node*)((intptr_t)0xdeadbeef);
 306   Node *n = use_blk;            // Get path input
 307   assert( use_blk != iff_dom, "" );
 308   // Here's the "spinup" the dominator tree loop.  Do a cache-check
 309   // along the way, in case we've come this way before.
 310   while( n != iff_dom ) {       // Found post-dominating point?
 311     prior_n = n;
 312     n = idom(n);                // Search higher
 313     Node *s = cache->probe( prior_n ); // Check cache
 314     if( s ) return s;           // Cache hit!
 315   }
 316 
 317   Node *phi_post;
 318   if( prior_n == new_false || prior_n == new_true ) {
 319     phi_post = def->clone();
 320     phi_post->set_req(0, prior_n );
 321     register_new_node(phi_post, prior_n);
 322   } else {
 323     // This method handles both control uses (looking for Regions) or data
 324     // uses (looking for Phis).  If looking for a control use, then we need
 325     // to insert a Region instead of a Phi; however Regions always exist
 326     // previously (the hash_find_insert below would always hit) so we can
 327     // return the existing Region.
 328     if( def->is_CFG() ) {
 329       phi_post = prior_n;       // If looking for CFG, return prior
 330     } else {
 331       assert( def->is_Phi(), "" );
 332       assert( prior_n->is_Region(), "must be a post-dominating merge point" );
 333 
 334       // Need a Phi here
 335       phi_post = PhiNode::make_blank(prior_n, def);
 336       // Search for both true and false on all paths till find one.
 337       for( uint i = 1; i < phi_post->req(); i++ ) // For all paths
 338         phi_post->init_req( i, spinup( iff_dom, new_false, new_true, prior_n->in(i), def, cache ) );
 339       Node *t = _igvn.hash_find_insert(phi_post);
 340       if( t ) {                 // See if we already have this one
 341         // phi_post will not be used, so kill it
 342         _igvn.remove_dead_node(phi_post);
 343         phi_post->destruct();
 344         phi_post = t;
 345       } else {
 346         register_new_node( phi_post, prior_n );
 347       }
 348     }
 349   }
 350 
 351   // Update cache everywhere
 352   prior_n = (Node*)((intptr_t)0xdeadbeef);  // Reset IDOM walk
 353   n = use_blk;                  // Get path input
 354   // Spin-up the idom tree again, basically doing path-compression.
 355   // Insert cache entries along the way, so that if we ever hit this
 356   // point in the IDOM tree again we'll stop immediately on a cache hit.
 357   while( n != iff_dom ) {       // Found post-dominating point?
 358     prior_n = n;
 359     n = idom(n);                // Search higher
 360     cache->lru_insert( prior_n, phi_post ); // Fill cache
 361   } // End of while not gone high enough
 362 
 363   return phi_post;
 364 }
 365 
 366 //------------------------------find_use_block---------------------------------
 367 // Find the block a USE is in.  Normally USE's are in the same block as the
 368 // using instruction.  For Phi-USE's, the USE is in the predecessor block
 369 // along the corresponding path.
 370 Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true ) {
 371   // CFG uses are their own block
 372   if( use->is_CFG() )
 373     return use;
 374 
 375   if( use->is_Phi() ) {         // Phi uses in prior block
 376     // Grab the first Phi use; there may be many.
 377     // Each will be handled as a separate iteration of
 378     // the "while( phi->outcnt() )" loop.
 379     uint j;
 380     for( j = 1; j < use->req(); j++ )
 381       if( use->in(j) == def )
 382         break;
 383     assert( j < use->req(), "def should be among use's inputs" );
 384     return use->in(0)->in(j);
 385   }
 386   // Normal (non-phi) use
 387   Node *use_blk = get_ctrl(use);
 388   // Some uses are directly attached to the old (and going away)
 389   // false and true branches.
 390   if( use_blk == old_false ) {
 391     use_blk = new_false;
 392     set_ctrl(use, new_false);
 393   }
 394   if( use_blk == old_true ) {
 395     use_blk = new_true;
 396     set_ctrl(use, new_true);
 397   }
 398 
 399   if (use_blk == NULL) {        // He's dead, Jim
 400     _igvn.replace_node(use, C->top());
 401   }
 402 
 403   return use_blk;
 404 }
 405 
 406 //------------------------------handle_use-------------------------------------
 407 // Handle uses of the merge point.  Basically, split-if makes the merge point
 408 // go away so all uses of the merge point must go away as well.  Most block
 409 // local uses have already been split-up, through the merge point.  Uses from
 410 // far below the merge point can't always be split up (e.g., phi-uses are
 411 // pinned) and it makes too much stuff live.  Instead we use a path-based
 412 // solution to move uses down.
 413 //
 414 // If the use is along the pre-split-CFG true branch, then the new use will
 415 // be from the post-split-CFG true merge point.  Vice-versa for the false
 416 // path.  Some uses will be along both paths; then we sink the use to the
 417 // post-dominating location; we may need to insert a Phi there.
 418 void PhaseIdealLoop::handle_use( Node *use, Node *def, small_cache *cache, Node *region_dom, Node *new_false, Node *new_true, Node *old_false, Node *old_true ) {
 419 
 420   Node *use_blk = find_use_block(use,def,old_false,new_false,old_true,new_true);
 421   if( !use_blk ) return;        // He's dead, Jim
 422 
 423   // Walk up the dominator tree until I hit either the old IfFalse, the old
 424   // IfTrue or the old If.  Insert Phis where needed.
 425   Node *new_def = spinup( region_dom, new_false, new_true, use_blk, def, cache );
 426 
 427   // Found where this USE goes.  Re-point him.
 428   uint i;
 429   for( i = 0; i < use->req(); i++ )
 430     if( use->in(i) == def )
 431       break;
 432   assert( i < use->req(), "def should be among use's inputs" );
 433   _igvn.replace_input_of(use, i, new_def);
 434 }
 435 
 436 //------------------------------do_split_if------------------------------------
 437 // Found an If getting its condition-code input from a Phi in the same block.
 438 // Split thru the Region.
 439 void PhaseIdealLoop::do_split_if( Node *iff ) {
 440   if (PrintOpto && VerifyLoopOptimizations) {
 441     tty->print_cr("Split-if");
 442   }
 443   if (TraceLoopOpts) {
 444     tty->print_cr("SplitIf");
 445   }
 446 
 447   C->set_major_progress();
 448   Node *region = iff->in(0);
 449   Node *region_dom = idom(region);
 450 
 451   // We are going to clone this test (and the control flow with it) up through
 452   // the incoming merge point.  We need to empty the current basic block.
 453   // Clone any instructions which must be in this block up through the merge
 454   // point.
 455   DUIterator i, j;
 456   bool progress = true;
 457   while (progress) {
 458     progress = false;
 459     for (i = region->outs(); region->has_out(i); i++) {
 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         }
 481         else if (m != iff && split_up(m, region, iff)) {
 482           // fall through
 483         } else {
 484           continue;
 485         }
 486         // Something unpredictable changed.
 487         // Tell the iterators to refresh themselves, and rerun the loop.
 488         i = region->refresh_out_pos(i);
 489         j = region->refresh_out_pos(j);
 490         progress = true;
 491       }
 492     }
 493   }
 494 
 495   // Now we have no instructions in the block containing the IF.
 496   // Split the IF.
 497   Node *new_iff = split_thru_region( iff, region );
 498 
 499   // Replace both uses of 'new_iff' with Regions merging True/False
 500   // paths.  This makes 'new_iff' go dead.
 501   Node *old_false = NULL, *old_true = NULL;
 502   Node *new_false = NULL, *new_true = NULL;
 503   for (DUIterator_Last j2min, j2 = iff->last_outs(j2min); j2 >= j2min; --j2) {
 504     Node *ifp = iff->last_out(j2);
 505     assert( ifp->Opcode() == Op_IfFalse || ifp->Opcode() == Op_IfTrue, "" );
 506     ifp->set_req(0, new_iff);
 507     Node *ifpx = split_thru_region( ifp, region );
 508 
 509     // Replace 'If' projection of a Region with a Region of
 510     // 'If' projections.
 511     ifpx->set_req(0, ifpx);       // A TRUE RegionNode
 512 
 513     // Setup dominator info
 514     set_idom(ifpx, region_dom, dom_depth(region_dom) + 1);
 515 
 516     // Check for splitting loop tails
 517     if( get_loop(iff)->tail() == ifp )
 518       get_loop(iff)->_tail = ifpx;
 519 
 520     // Replace in the graph with lazy-update mechanism
 521     new_iff->set_req(0, new_iff); // hook self so it does not go dead
 522     lazy_replace(ifp, ifpx);
 523     new_iff->set_req(0, region);
 524 
 525     // Record bits for later xforms
 526     if( ifp->Opcode() == Op_IfFalse ) {
 527       old_false = ifp;
 528       new_false = ifpx;
 529     } else {
 530       old_true = ifp;
 531       new_true = ifpx;
 532     }
 533   }
 534   _igvn.remove_dead_node(new_iff);
 535   // Lazy replace IDOM info with the region's dominator
 536   lazy_replace( iff, region_dom );
 537 
 538   // Now make the original merge point go dead, by handling all its uses.
 539   small_cache region_cache;
 540   // Preload some control flow in region-cache
 541   region_cache.lru_insert( new_false, new_false );
 542   region_cache.lru_insert( new_true , new_true  );
 543   // Now handle all uses of the splitting block
 544   for (DUIterator k = region->outs(); region->has_out(k); k++) {
 545     Node* phi = region->out(k);
 546     if (!phi->in(0)) {         // Dead phi?  Remove it
 547       _igvn.remove_dead_node(phi);
 548     } else if (phi == region) { // Found the self-reference
 549       continue;                 // No roll-back of DUIterator
 550     } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
 551       assert(phi->in(0) == region, "Inconsistent graph");
 552       // Need a per-def cache.  Phi represents a def, so make a cache
 553       small_cache phi_cache;
 554 
 555       // Inspect all Phi uses to make the Phi go dead
 556       for (DUIterator_Last lmin, l = phi->last_outs(lmin); l >= lmin; --l) {
 557         Node* use = phi->last_out(l);
 558         // Compute the new DEF for this USE.  New DEF depends on the path
 559         // taken from the original DEF to the USE.  The new DEF may be some
 560         // collection of PHI's merging values from different paths.  The Phis
 561         // inserted depend only on the location of the USE.  We use a
 562         // 2-element cache to handle multiple uses from the same block.
 563         handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
 564       } // End of while phi has uses
 565       // Remove the dead Phi
 566       _igvn.remove_dead_node( phi );
 567     } else {
 568       assert(phi->in(0) == region, "Inconsistent graph");
 569       // Random memory op guarded by Region.  Compute new DEF for USE.
 570       handle_use(phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true);
 571     }
 572     // Every path above deletes a use of the region, except for the region
 573     // self-cycle (which is needed by handle_use calling find_use_block
 574     // calling get_ctrl calling get_ctrl_no_update looking for dead
 575     // regions).  So roll back the DUIterator innards.
 576     --k;
 577   } // End of while merge point has phis
 578 
 579   assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
 580   region->set_req(0, NULL);       // Break the self-cycle
 581 
 582   // Any leftover bits in the splitting block must not have depended on local
 583   // Phi inputs (these have already been split-up).  Hence it's safe to hoist
 584   // these guys to the dominating point.
 585   lazy_replace( region, region_dom );
 586 #ifndef PRODUCT
 587   if( VerifyLoopOptimizations ) verify();
 588 #endif
 589 }