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