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 RegionNode* PhaseIdealLoop::split_thru_region(Node* n, RegionNode* region) {
 35   assert(n->is_CFG(), "");
 36   RegionNode* r = new RegionNode(region->req());
 37   IdealLoopTree* loop = get_loop(n);
 38   for (uint i = 1; i < region->req(); i++) {
 39     Node* x = n->clone();
 40     Node* in0 = n->in(0);
 41     if (in0->in(0) == region) x->set_req(0, in0->in(i));
 42     for (uint j = 1; j < n->req(); j++) {
 43       Node* in = n->in(j);
 44       if (get_ctrl(in) == region) {
 45         x->set_req(j, in->in(i));
 46       }
 47     }
 48     _igvn.register_new_node_with_optimizer(x);
 49     set_loop(x, loop);
 50     set_idom(x, x->in(0), dom_depth(x->in(0))+1);
 51     r->init_req(i, x);
 52   }
 53 
 54   // Record region
 55   r->set_req(0,region);         // Not a TRUE RegionNode
 56   _igvn.register_new_node_with_optimizer(r);
 57   set_loop(r, loop);
 58   if (!loop->_child) {
 59     loop->_body.push(r);
 60   }
 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       if (!n->is_FastLock()) {
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       }
185       // Clone down this CmpNode
186       for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin; --j) {
187         Node* use = n->last_out(j);
188         uint pos = 1;
189         if (n->is_FastLock()) {
190           pos = TypeFunc::Parms + 2;
191           assert(use->is_Lock(), "FastLock only used by LockNode");
192         }
193         assert(use->in(pos) == n, "" );
194         Node *x = n->clone();
195         register_new_node(x, ctrl_or_self(use));
196         _igvn.replace_input_of(use, pos, x);
197       }
198       _igvn.remove_dead_node( n );
199 
200       return true;
201     }
202   }
203   if (subgraph_has_opaque(n)) {
204     Unique_Node_List wq;
205     wq.push(n);
206     for (uint i = 0; i < wq.size(); i++) {
207       Node* m = wq.at(i);
208       if (m->is_If()) {
209         assert(skeleton_predicate_has_opaque(m->as_If()), "opaque node not reachable from if?");
210         Node* bol = clone_skeleton_predicate_bool(m, NULL, NULL, m->in(0));
211         _igvn.replace_input_of(m, 1, bol);
212       } else {
213         assert(!m->is_CFG(), "not CFG expected");
214         for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) {
215           Node* u = m->fast_out(j);
216           wq.push(u);
217         }
218       }
219     }
220   }
221 
222   // See if splitting-up a Store.  Any anti-dep loads must go up as
223   // well.  An anti-dep load might be in the wrong block, because in
224   // this particular layout/schedule we ignored anti-deps and allow
225   // memory to be alive twice.  This only works if we do the same
226   // operations on anti-dep loads as we do their killing stores.
227   if( n->is_Store() && n->in(MemNode::Memory)->in(0) == n->in(0) ) {
228     // Get store's memory slice
229     int alias_idx = C->get_alias_index(_igvn.type(n->in(MemNode::Address))->is_ptr());
230 
231     // Get memory-phi anti-dep loads will be using
232     Node *memphi = n->in(MemNode::Memory);
233     assert( memphi->is_Phi(), "" );
234     // Hoist any anti-dep load to the splitting block;
235     // it will then "split-up".
236     for (DUIterator_Fast imax,i = memphi->fast_outs(imax); i < imax; i++) {
237       Node *load = memphi->fast_out(i);
238       if( load->is_Load() && alias_idx == C->get_alias_index(_igvn.type(load->in(MemNode::Address))->is_ptr()) )
239         set_ctrl(load,blk1);
240     }
241   }
242 
243   // Found some other Node; must clone it up
244 #ifndef PRODUCT
245   if( PrintOpto && VerifyLoopOptimizations ) {
246     tty->print("Cloning up: ");
247     n->dump();
248   }
249 #endif
250 
251   // ConvI2L may have type information on it which becomes invalid if
252   // it moves up in the graph so change any clones so widen the type
253   // to TypeLong::INT when pushing it up.
254   const Type* rtype = NULL;
255   if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::INT) {
256     rtype = TypeLong::INT;
257   }
258 
259   // Now actually split-up this guy.  One copy per control path merging.
260   Node *phi = PhiNode::make_blank(blk1, n);
261   for( uint j = 1; j < blk1->req(); j++ ) {
262     Node *x = n->clone();
263     // Widen the type of the ConvI2L when pushing up.
264     if (rtype != NULL) x->as_Type()->set_type(rtype);
265     if( n->in(0) && n->in(0) == blk1 )
266       x->set_req( 0, blk1->in(j) );
267     for( uint i = 1; i < n->req(); i++ ) {
268       Node *m = n->in(i);
269       if( get_ctrl(m) == blk1 ) {
270         assert( m->in(0) == blk1, "" );
271         x->set_req( i, m->in(j) );
272       }
273     }
274     register_new_node( x, blk1->in(j) );
275     phi->init_req( j, x );
276   }
277   // Announce phi to optimizer
278   register_new_node(phi, blk1);
279 
280   // Remove cloned-up value from optimizer; use phi instead
281   _igvn.replace_node( n, phi );
282 
283   // (There used to be a self-recursive call to split_up() here,
284   // but it is not needed.  All necessary forward walking is done
285   // by do_split_if() below.)
286 
287   return true;
288 }
289 
290 //------------------------------register_new_node------------------------------
291 void PhaseIdealLoop::register_new_node( Node *n, Node *blk ) {
292   assert(!n->is_CFG(), "must be data node");
293   _igvn.register_new_node_with_optimizer(n);
294   set_ctrl(n, blk);
295   IdealLoopTree *loop = get_loop(blk);
296   if( !loop->_child )
297     loop->_body.push(n);
298 }
299 
300 //------------------------------small_cache------------------------------------
301 struct small_cache : public Dict {
302 
303   small_cache() : Dict( cmpkey, hashptr ) {}
304   Node *probe( Node *use_blk ) { return (Node*)((*this)[use_blk]); }
305   void lru_insert( Node *use_blk, Node *new_def ) { Insert(use_blk,new_def); }
306 };
307 
308 //------------------------------spinup-----------------------------------------
309 // "Spin up" the dominator tree, starting at the use site and stopping when we
310 // find the post-dominating point.
311 
312 // We must be at the merge point which post-dominates 'new_false' and
313 // 'new_true'.  Figure out which edges into the RegionNode eventually lead up
314 // to false and which to true.  Put in a PhiNode to merge values; plug in
315 // the appropriate false-arm or true-arm values.  If some path leads to the
316 // original IF, then insert a Phi recursively.
317 Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, Node *use_blk, Node *def, small_cache *cache ) {
318   if (use_blk->is_top())        // Handle dead uses
319     return use_blk;
320   Node *prior_n = (Node*)((intptr_t)0xdeadbeef);
321   Node *n = use_blk;            // Get path input
322   assert( use_blk != iff_dom, "" );
323   // Here's the "spinup" the dominator tree loop.  Do a cache-check
324   // along the way, in case we've come this way before.
325   while( n != iff_dom ) {       // Found post-dominating point?
326     prior_n = n;
327     n = idom(n);                // Search higher
328     Node *s = cache->probe( prior_n ); // Check cache
329     if( s ) return s;           // Cache hit!
330   }
331 
332   Node *phi_post;
333   if( prior_n == new_false || prior_n == new_true ) {
334     phi_post = def->clone();
335     phi_post->set_req(0, prior_n );
336     register_new_node(phi_post, prior_n);
337   } else {
338     // This method handles both control uses (looking for Regions) or data
339     // uses (looking for Phis).  If looking for a control use, then we need
340     // to insert a Region instead of a Phi; however Regions always exist
341     // previously (the hash_find_insert below would always hit) so we can
342     // return the existing Region.
343     if( def->is_CFG() ) {
344       phi_post = prior_n;       // If looking for CFG, return prior
345     } else {
346       assert( def->is_Phi(), "" );
347       assert( prior_n->is_Region(), "must be a post-dominating merge point" );
348 
349       // Need a Phi here
350       phi_post = PhiNode::make_blank(prior_n, def);
351       // Search for both true and false on all paths till find one.
352       for( uint i = 1; i < phi_post->req(); i++ ) // For all paths
353         phi_post->init_req( i, spinup( iff_dom, new_false, new_true, prior_n->in(i), def, cache ) );
354       Node *t = _igvn.hash_find_insert(phi_post);
355       if( t ) {                 // See if we already have this one
356         // phi_post will not be used, so kill it
357         _igvn.remove_dead_node(phi_post);
358         phi_post->destruct(&_igvn);
359         phi_post = t;
360       } else {
361         register_new_node( phi_post, prior_n );
362       }
363     }
364   }
365 
366   // Update cache everywhere
367   prior_n = (Node*)((intptr_t)0xdeadbeef);  // Reset IDOM walk
368   n = use_blk;                  // Get path input
369   // Spin-up the idom tree again, basically doing path-compression.
370   // Insert cache entries along the way, so that if we ever hit this
371   // point in the IDOM tree again we'll stop immediately on a cache hit.
372   while( n != iff_dom ) {       // Found post-dominating point?
373     prior_n = n;
374     n = idom(n);                // Search higher
375     cache->lru_insert( prior_n, phi_post ); // Fill cache
376   } // End of while not gone high enough
377 
378   return phi_post;
379 }
380 
381 //------------------------------find_use_block---------------------------------
382 // Find the block a USE is in.  Normally USE's are in the same block as the
383 // using instruction.  For Phi-USE's, the USE is in the predecessor block
384 // along the corresponding path.
385 Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true ) {
386   // CFG uses are their own block
387   if( use->is_CFG() )
388     return use;
389 
390   if( use->is_Phi() ) {         // Phi uses in prior block
391     // Grab the first Phi use; there may be many.
392     // Each will be handled as a separate iteration of
393     // the "while( phi->outcnt() )" loop.
394     uint j;
395     for( j = 1; j < use->req(); j++ )
396       if( use->in(j) == def )
397         break;
398     assert( j < use->req(), "def should be among use's inputs" );
399     return use->in(0)->in(j);
400   }
401   // Normal (non-phi) use
402   Node *use_blk = get_ctrl(use);
403   // Some uses are directly attached to the old (and going away)
404   // false and true branches.
405   if( use_blk == old_false ) {
406     use_blk = new_false;
407     set_ctrl(use, new_false);
408   }
409   if( use_blk == old_true ) {
410     use_blk = new_true;
411     set_ctrl(use, new_true);
412   }
413 
414   if (use_blk == NULL) {        // He's dead, Jim
415     _igvn.replace_node(use, C->top());
416   }
417 
418   return use_blk;
419 }
420 
421 //------------------------------handle_use-------------------------------------
422 // Handle uses of the merge point.  Basically, split-if makes the merge point
423 // go away so all uses of the merge point must go away as well.  Most block
424 // local uses have already been split-up, through the merge point.  Uses from
425 // far below the merge point can't always be split up (e.g., phi-uses are
426 // pinned) and it makes too much stuff live.  Instead we use a path-based
427 // solution to move uses down.
428 //
429 // If the use is along the pre-split-CFG true branch, then the new use will
430 // be from the post-split-CFG true merge point.  Vice-versa for the false
431 // path.  Some uses will be along both paths; then we sink the use to the
432 // post-dominating location; we may need to insert a Phi there.
433 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 ) {
434 
435   Node *use_blk = find_use_block(use,def,old_false,new_false,old_true,new_true);
436   if( !use_blk ) return;        // He's dead, Jim
437 
438   // Walk up the dominator tree until I hit either the old IfFalse, the old
439   // IfTrue or the old If.  Insert Phis where needed.
440   Node *new_def = spinup( region_dom, new_false, new_true, use_blk, def, cache );
441 
442   // Found where this USE goes.  Re-point him.
443   uint i;
444   for( i = 0; i < use->req(); i++ )
445     if( use->in(i) == def )
446       break;
447   assert( i < use->req(), "def should be among use's inputs" );
448   _igvn.replace_input_of(use, i, new_def);
449 }
450 
451 //------------------------------do_split_if------------------------------------
452 // Found an If getting its condition-code input from a Phi in the same block.
453 // Split thru the Region.
454 void PhaseIdealLoop::do_split_if(Node* iff, RegionNode** new_false_region, RegionNode** new_true_region) {
455   if (PrintOpto && VerifyLoopOptimizations) {
456     tty->print_cr("Split-if");
457   }
458   if (TraceLoopOpts) {
459     tty->print_cr("SplitIf");
460   }
461 
462   C->set_major_progress();
463   RegionNode *region = iff->in(0)->as_Region();
464   Node *region_dom = idom(region);
465 
466   // We are going to clone this test (and the control flow with it) up through
467   // the incoming merge point.  We need to empty the current basic block.
468   // Clone any instructions which must be in this block up through the merge
469   // point.
470   DUIterator i, j;
471   bool progress = true;
472   while (progress) {
473     progress = false;
474     for (i = region->outs(); region->has_out(i); i++) {
475       Node* n = region->out(i);
476       if( n == region ) continue;
477       // The IF to be split is OK.
478       if( n == iff ) continue;
479       if( !n->is_Phi() ) {      // Found pinned memory op or such
480         if (split_up(n, region, iff)) {
481           i = region->refresh_out_pos(i);
482           progress = true;
483         }
484         continue;
485       }
486       assert( n->in(0) == region, "" );
487 
488       // Recursively split up all users of a Phi
489       for (j = n->outs(); n->has_out(j); j++) {
490         Node* m = n->out(j);
491         // If m is dead, throw it away, and declare progress
492         if (_nodes[m->_idx] == NULL) {
493           _igvn.remove_dead_node(m);
494           // fall through
495         }
496         else if (m != iff && split_up(m, region, iff)) {
497           // fall through
498         } else {
499           continue;
500         }
501         // Something unpredictable changed.
502         // Tell the iterators to refresh themselves, and rerun the loop.
503         i = region->refresh_out_pos(i);
504         j = region->refresh_out_pos(j);
505         progress = true;
506       }
507     }
508   }
509 
510   // Now we have no instructions in the block containing the IF.
511   // Split the IF.
512   RegionNode *new_iff = split_thru_region(iff, region);
513 
514   // Replace both uses of 'new_iff' with Regions merging True/False
515   // paths.  This makes 'new_iff' go dead.
516   Node *old_false = NULL, *old_true = NULL;
517   RegionNode* new_false = NULL;
518   RegionNode* new_true = NULL;
519   for (DUIterator_Last j2min, j2 = iff->last_outs(j2min); j2 >= j2min; --j2) {
520     Node *ifp = iff->last_out(j2);
521     assert( ifp->Opcode() == Op_IfFalse || ifp->Opcode() == Op_IfTrue, "" );
522     ifp->set_req(0, new_iff);
523     RegionNode* ifpx = split_thru_region(ifp, region);
524 
525     // Replace 'If' projection of a Region with a Region of
526     // 'If' projections.
527     ifpx->set_req(0, ifpx);       // A TRUE RegionNode
528 
529     // Setup dominator info
530     set_idom(ifpx, region_dom, dom_depth(region_dom) + 1);
531 
532     // Check for splitting loop tails
533     if( get_loop(iff)->tail() == ifp )
534       get_loop(iff)->_tail = ifpx;
535 
536     // Replace in the graph with lazy-update mechanism
537     new_iff->set_req(0, new_iff); // hook self so it does not go dead
538     lazy_replace(ifp, ifpx);
539     new_iff->set_req(0, region);
540 
541     // Record bits for later xforms
542     if( ifp->Opcode() == Op_IfFalse ) {
543       old_false = ifp;
544       new_false = ifpx;
545     } else {
546       old_true = ifp;
547       new_true = ifpx;
548     }
549   }
550   _igvn.remove_dead_node(new_iff);
551   // Lazy replace IDOM info with the region's dominator
552   lazy_replace(iff, region_dom);
553   lazy_update(region, region_dom); // idom must be update before handle_uses
554   region->set_req(0, NULL);        // Break the self-cycle. Required for lazy_update to work on region
555 
556   // Now make the original merge point go dead, by handling all its uses.
557   small_cache region_cache;
558   // Preload some control flow in region-cache
559   region_cache.lru_insert( new_false, new_false );
560   region_cache.lru_insert( new_true , new_true  );
561   // Now handle all uses of the splitting block
562   for (DUIterator k = region->outs(); region->has_out(k); k++) {
563     Node* phi = region->out(k);
564     if (!phi->in(0)) {         // Dead phi?  Remove it
565       _igvn.remove_dead_node(phi);
566     } else if (phi == region) { // Found the self-reference
567       continue;                 // No roll-back of DUIterator
568     } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
569       assert(phi->in(0) == region, "Inconsistent graph");
570       // Need a per-def cache.  Phi represents a def, so make a cache
571       small_cache phi_cache;
572 
573       // Inspect all Phi uses to make the Phi go dead
574       for (DUIterator_Last lmin, l = phi->last_outs(lmin); l >= lmin; --l) {
575         Node* use = phi->last_out(l);
576         // Compute the new DEF for this USE.  New DEF depends on the path
577         // taken from the original DEF to the USE.  The new DEF may be some
578         // collection of PHI's merging values from different paths.  The Phis
579         // inserted depend only on the location of the USE.  We use a
580         // 2-element cache to handle multiple uses from the same block.
581         handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
582       } // End of while phi has uses
583       // Remove the dead Phi
584       _igvn.remove_dead_node( phi );
585     } else {
586       assert(phi->in(0) == region, "Inconsistent graph");
587       // Random memory op guarded by Region.  Compute new DEF for USE.
588       handle_use(phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true);
589     }
590     // Every path above deletes a use of the region, except for the region
591     // self-cycle (which is needed by handle_use calling find_use_block
592     // calling get_ctrl calling get_ctrl_no_update looking for dead
593     // regions).  So roll back the DUIterator innards.
594     --k;
595   } // End of while merge point has phis
596 
597   _igvn.remove_dead_node(region);
598 
599   if (new_false_region != NULL) {
600     *new_false_region = new_false;
601   }
602   if (new_true_region != NULL) {
603     *new_true_region = new_true;
604   }
605 
606 #ifndef PRODUCT
607   if( VerifyLoopOptimizations ) verify();
608 #endif
609 }