1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/split_if.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,542 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "memory/allocation.inline.hpp" 1.30 +#include "opto/callnode.hpp" 1.31 +#include "opto/connode.hpp" 1.32 +#include "opto/loopnode.hpp" 1.33 + 1.34 + 1.35 +//------------------------------split_thru_region------------------------------ 1.36 +// Split Node 'n' through merge point. 1.37 +Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) { 1.38 + uint wins = 0; 1.39 + assert( n->is_CFG(), "" ); 1.40 + assert( region->is_Region(), "" ); 1.41 + Node *r = new (C) RegionNode( region->req() ); 1.42 + IdealLoopTree *loop = get_loop( n ); 1.43 + for( uint i = 1; i < region->req(); i++ ) { 1.44 + Node *x = n->clone(); 1.45 + Node *in0 = n->in(0); 1.46 + if( in0->in(0) == region ) x->set_req( 0, in0->in(i) ); 1.47 + for( uint j = 1; j < n->req(); j++ ) { 1.48 + Node *in = n->in(j); 1.49 + if( get_ctrl(in) == region ) 1.50 + x->set_req( j, in->in(i) ); 1.51 + } 1.52 + _igvn.register_new_node_with_optimizer(x); 1.53 + set_loop(x, loop); 1.54 + set_idom(x, x->in(0), dom_depth(x->in(0))+1); 1.55 + r->init_req(i, x); 1.56 + } 1.57 + 1.58 + // Record region 1.59 + r->set_req(0,region); // Not a TRUE RegionNode 1.60 + _igvn.register_new_node_with_optimizer(r); 1.61 + set_loop(r, loop); 1.62 + if( !loop->_child ) 1.63 + loop->_body.push(r); 1.64 + return r; 1.65 +} 1.66 + 1.67 +//------------------------------split_up--------------------------------------- 1.68 +// Split block-local op up through the phis to empty the current block 1.69 +bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) { 1.70 + if( n->is_CFG() ) { 1.71 + assert( n->in(0) != blk1, "Lousy candidate for split-if" ); 1.72 + return false; 1.73 + } 1.74 + if( get_ctrl(n) != blk1 && get_ctrl(n) != blk2 ) 1.75 + return false; // Not block local 1.76 + if( n->is_Phi() ) return false; // Local PHIs are expected 1.77 + 1.78 + // Recursively split-up inputs 1.79 + for (uint i = 1; i < n->req(); i++) { 1.80 + if( split_up( n->in(i), blk1, blk2 ) ) { 1.81 + // Got split recursively and self went dead? 1.82 + if (n->outcnt() == 0) 1.83 + _igvn.remove_dead_node(n); 1.84 + return true; 1.85 + } 1.86 + } 1.87 + 1.88 + // Check for needing to clone-up a compare. Can't do that, it forces 1.89 + // another (nested) split-if transform. Instead, clone it "down". 1.90 + if( n->is_Cmp() ) { 1.91 + assert(get_ctrl(n) == blk2 || get_ctrl(n) == blk1, "must be in block with IF"); 1.92 + // Check for simple Cmp/Bool/CMove which we can clone-up. Cmp/Bool/CMove 1.93 + // sequence can have no other users and it must all reside in the split-if 1.94 + // block. Non-simple Cmp/Bool/CMove sequences are 'cloned-down' below - 1.95 + // private, per-use versions of the Cmp and Bool are made. These sink to 1.96 + // the CMove block. If the CMove is in the split-if block, then in the 1.97 + // next iteration this will become a simple Cmp/Bool/CMove set to clone-up. 1.98 + Node *bol, *cmov; 1.99 + if( !(n->outcnt() == 1 && n->unique_out()->is_Bool() && 1.100 + (bol = n->unique_out()->as_Bool()) && 1.101 + (get_ctrl(bol) == blk1 || 1.102 + get_ctrl(bol) == blk2) && 1.103 + bol->outcnt() == 1 && 1.104 + bol->unique_out()->is_CMove() && 1.105 + (cmov = bol->unique_out()->as_CMove()) && 1.106 + (get_ctrl(cmov) == blk1 || 1.107 + get_ctrl(cmov) == blk2) ) ) { 1.108 + 1.109 + // Must clone down 1.110 +#ifndef PRODUCT 1.111 + if( PrintOpto && VerifyLoopOptimizations ) { 1.112 + tty->print("Cloning down: "); 1.113 + n->dump(); 1.114 + } 1.115 +#endif 1.116 + // Clone down any block-local BoolNode uses of this CmpNode 1.117 + for (DUIterator i = n->outs(); n->has_out(i); i++) { 1.118 + Node* bol = n->out(i); 1.119 + assert( bol->is_Bool(), "" ); 1.120 + if (bol->outcnt() == 1) { 1.121 + Node* use = bol->unique_out(); 1.122 + Node *use_c = use->is_If() ? use->in(0) : get_ctrl(use); 1.123 + if (use_c == blk1 || use_c == blk2) { 1.124 + continue; 1.125 + } 1.126 + } 1.127 + if (get_ctrl(bol) == blk1 || get_ctrl(bol) == blk2) { 1.128 + // Recursively sink any BoolNode 1.129 +#ifndef PRODUCT 1.130 + if( PrintOpto && VerifyLoopOptimizations ) { 1.131 + tty->print("Cloning down: "); 1.132 + bol->dump(); 1.133 + } 1.134 +#endif 1.135 + for (DUIterator_Last jmin, j = bol->last_outs(jmin); j >= jmin; --j) { 1.136 + // Uses are either IfNodes or CMoves 1.137 + Node* iff = bol->last_out(j); 1.138 + assert( iff->in(1) == bol, "" ); 1.139 + // Get control block of either the CMove or the If input 1.140 + Node *iff_ctrl = iff->is_If() ? iff->in(0) : get_ctrl(iff); 1.141 + Node *x = bol->clone(); 1.142 + register_new_node(x, iff_ctrl); 1.143 + _igvn.replace_input_of(iff, 1, x); 1.144 + } 1.145 + _igvn.remove_dead_node( bol ); 1.146 + --i; 1.147 + } 1.148 + } 1.149 + // Clone down this CmpNode 1.150 + for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin; --j) { 1.151 + Node* bol = n->last_out(j); 1.152 + assert( bol->in(1) == n, "" ); 1.153 + Node *x = n->clone(); 1.154 + register_new_node(x, get_ctrl(bol)); 1.155 + _igvn.replace_input_of(bol, 1, x); 1.156 + } 1.157 + _igvn.remove_dead_node( n ); 1.158 + 1.159 + return true; 1.160 + } 1.161 + } 1.162 + 1.163 + // See if splitting-up a Store. Any anti-dep loads must go up as 1.164 + // well. An anti-dep load might be in the wrong block, because in 1.165 + // this particular layout/schedule we ignored anti-deps and allow 1.166 + // memory to be alive twice. This only works if we do the same 1.167 + // operations on anti-dep loads as we do their killing stores. 1.168 + if( n->is_Store() && n->in(MemNode::Memory)->in(0) == n->in(0) ) { 1.169 + // Get store's memory slice 1.170 + int alias_idx = C->get_alias_index(_igvn.type(n->in(MemNode::Address))->is_ptr()); 1.171 + 1.172 + // Get memory-phi anti-dep loads will be using 1.173 + Node *memphi = n->in(MemNode::Memory); 1.174 + assert( memphi->is_Phi(), "" ); 1.175 + // Hoist any anti-dep load to the splitting block; 1.176 + // it will then "split-up". 1.177 + for (DUIterator_Fast imax,i = memphi->fast_outs(imax); i < imax; i++) { 1.178 + Node *load = memphi->fast_out(i); 1.179 + if( load->is_Load() && alias_idx == C->get_alias_index(_igvn.type(load->in(MemNode::Address))->is_ptr()) ) 1.180 + set_ctrl(load,blk1); 1.181 + } 1.182 + } 1.183 + 1.184 + // Found some other Node; must clone it up 1.185 +#ifndef PRODUCT 1.186 + if( PrintOpto && VerifyLoopOptimizations ) { 1.187 + tty->print("Cloning up: "); 1.188 + n->dump(); 1.189 + } 1.190 +#endif 1.191 + 1.192 + // ConvI2L may have type information on it which becomes invalid if 1.193 + // it moves up in the graph so change any clones so widen the type 1.194 + // to TypeLong::INT when pushing it up. 1.195 + const Type* rtype = NULL; 1.196 + if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::INT) { 1.197 + rtype = TypeLong::INT; 1.198 + } 1.199 + 1.200 + // Now actually split-up this guy. One copy per control path merging. 1.201 + Node *phi = PhiNode::make_blank(blk1, n); 1.202 + for( uint j = 1; j < blk1->req(); j++ ) { 1.203 + Node *x = n->clone(); 1.204 + // Widen the type of the ConvI2L when pushing up. 1.205 + if (rtype != NULL) x->as_Type()->set_type(rtype); 1.206 + if( n->in(0) && n->in(0) == blk1 ) 1.207 + x->set_req( 0, blk1->in(j) ); 1.208 + for( uint i = 1; i < n->req(); i++ ) { 1.209 + Node *m = n->in(i); 1.210 + if( get_ctrl(m) == blk1 ) { 1.211 + assert( m->in(0) == blk1, "" ); 1.212 + x->set_req( i, m->in(j) ); 1.213 + } 1.214 + } 1.215 + register_new_node( x, blk1->in(j) ); 1.216 + phi->init_req( j, x ); 1.217 + } 1.218 + // Announce phi to optimizer 1.219 + register_new_node(phi, blk1); 1.220 + 1.221 + // Remove cloned-up value from optimizer; use phi instead 1.222 + _igvn.replace_node( n, phi ); 1.223 + 1.224 + // (There used to be a self-recursive call to split_up() here, 1.225 + // but it is not needed. All necessary forward walking is done 1.226 + // by do_split_if() below.) 1.227 + 1.228 + return true; 1.229 +} 1.230 + 1.231 +//------------------------------register_new_node------------------------------ 1.232 +void PhaseIdealLoop::register_new_node( Node *n, Node *blk ) { 1.233 + assert(!n->is_CFG(), "must be data node"); 1.234 + _igvn.register_new_node_with_optimizer(n); 1.235 + set_ctrl(n, blk); 1.236 + IdealLoopTree *loop = get_loop(blk); 1.237 + if( !loop->_child ) 1.238 + loop->_body.push(n); 1.239 +} 1.240 + 1.241 +//------------------------------small_cache------------------------------------ 1.242 +struct small_cache : public Dict { 1.243 + 1.244 + small_cache() : Dict( cmpkey, hashptr ) {} 1.245 + Node *probe( Node *use_blk ) { return (Node*)((*this)[use_blk]); } 1.246 + void lru_insert( Node *use_blk, Node *new_def ) { Insert(use_blk,new_def); } 1.247 +}; 1.248 + 1.249 +//------------------------------spinup----------------------------------------- 1.250 +// "Spin up" the dominator tree, starting at the use site and stopping when we 1.251 +// find the post-dominating point. 1.252 + 1.253 +// We must be at the merge point which post-dominates 'new_false' and 1.254 +// 'new_true'. Figure out which edges into the RegionNode eventually lead up 1.255 +// to false and which to true. Put in a PhiNode to merge values; plug in 1.256 +// the appropriate false-arm or true-arm values. If some path leads to the 1.257 +// original IF, then insert a Phi recursively. 1.258 +Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, Node *use_blk, Node *def, small_cache *cache ) { 1.259 + if (use_blk->is_top()) // Handle dead uses 1.260 + return use_blk; 1.261 + Node *prior_n = (Node*)0xdeadbeef; 1.262 + Node *n = use_blk; // Get path input 1.263 + assert( use_blk != iff_dom, "" ); 1.264 + // Here's the "spinup" the dominator tree loop. Do a cache-check 1.265 + // along the way, in case we've come this way before. 1.266 + while( n != iff_dom ) { // Found post-dominating point? 1.267 + prior_n = n; 1.268 + n = idom(n); // Search higher 1.269 + Node *s = cache->probe( prior_n ); // Check cache 1.270 + if( s ) return s; // Cache hit! 1.271 + } 1.272 + 1.273 + Node *phi_post; 1.274 + if( prior_n == new_false || prior_n == new_true ) { 1.275 + phi_post = def->clone(); 1.276 + phi_post->set_req(0, prior_n ); 1.277 + register_new_node(phi_post, prior_n); 1.278 + } else { 1.279 + // This method handles both control uses (looking for Regions) or data 1.280 + // uses (looking for Phis). If looking for a control use, then we need 1.281 + // to insert a Region instead of a Phi; however Regions always exist 1.282 + // previously (the hash_find_insert below would always hit) so we can 1.283 + // return the existing Region. 1.284 + if( def->is_CFG() ) { 1.285 + phi_post = prior_n; // If looking for CFG, return prior 1.286 + } else { 1.287 + assert( def->is_Phi(), "" ); 1.288 + assert( prior_n->is_Region(), "must be a post-dominating merge point" ); 1.289 + 1.290 + // Need a Phi here 1.291 + phi_post = PhiNode::make_blank(prior_n, def); 1.292 + // Search for both true and false on all paths till find one. 1.293 + for( uint i = 1; i < phi_post->req(); i++ ) // For all paths 1.294 + phi_post->init_req( i, spinup( iff_dom, new_false, new_true, prior_n->in(i), def, cache ) ); 1.295 + Node *t = _igvn.hash_find_insert(phi_post); 1.296 + if( t ) { // See if we already have this one 1.297 + // phi_post will not be used, so kill it 1.298 + _igvn.remove_dead_node(phi_post); 1.299 + phi_post->destruct(); 1.300 + phi_post = t; 1.301 + } else { 1.302 + register_new_node( phi_post, prior_n ); 1.303 + } 1.304 + } 1.305 + } 1.306 + 1.307 + // Update cache everywhere 1.308 + prior_n = (Node*)0xdeadbeef; // Reset IDOM walk 1.309 + n = use_blk; // Get path input 1.310 + // Spin-up the idom tree again, basically doing path-compression. 1.311 + // Insert cache entries along the way, so that if we ever hit this 1.312 + // point in the IDOM tree again we'll stop immediately on a cache hit. 1.313 + while( n != iff_dom ) { // Found post-dominating point? 1.314 + prior_n = n; 1.315 + n = idom(n); // Search higher 1.316 + cache->lru_insert( prior_n, phi_post ); // Fill cache 1.317 + } // End of while not gone high enough 1.318 + 1.319 + return phi_post; 1.320 +} 1.321 + 1.322 +//------------------------------find_use_block--------------------------------- 1.323 +// Find the block a USE is in. Normally USE's are in the same block as the 1.324 +// using instruction. For Phi-USE's, the USE is in the predecessor block 1.325 +// along the corresponding path. 1.326 +Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true ) { 1.327 + // CFG uses are their own block 1.328 + if( use->is_CFG() ) 1.329 + return use; 1.330 + 1.331 + if( use->is_Phi() ) { // Phi uses in prior block 1.332 + // Grab the first Phi use; there may be many. 1.333 + // Each will be handled as a separate iteration of 1.334 + // the "while( phi->outcnt() )" loop. 1.335 + uint j; 1.336 + for( j = 1; j < use->req(); j++ ) 1.337 + if( use->in(j) == def ) 1.338 + break; 1.339 + assert( j < use->req(), "def should be among use's inputs" ); 1.340 + return use->in(0)->in(j); 1.341 + } 1.342 + // Normal (non-phi) use 1.343 + Node *use_blk = get_ctrl(use); 1.344 + // Some uses are directly attached to the old (and going away) 1.345 + // false and true branches. 1.346 + if( use_blk == old_false ) { 1.347 + use_blk = new_false; 1.348 + set_ctrl(use, new_false); 1.349 + } 1.350 + if( use_blk == old_true ) { 1.351 + use_blk = new_true; 1.352 + set_ctrl(use, new_true); 1.353 + } 1.354 + 1.355 + if (use_blk == NULL) { // He's dead, Jim 1.356 + _igvn.replace_node(use, C->top()); 1.357 + } 1.358 + 1.359 + return use_blk; 1.360 +} 1.361 + 1.362 +//------------------------------handle_use------------------------------------- 1.363 +// Handle uses of the merge point. Basically, split-if makes the merge point 1.364 +// go away so all uses of the merge point must go away as well. Most block 1.365 +// local uses have already been split-up, through the merge point. Uses from 1.366 +// far below the merge point can't always be split up (e.g., phi-uses are 1.367 +// pinned) and it makes too much stuff live. Instead we use a path-based 1.368 +// solution to move uses down. 1.369 +// 1.370 +// If the use is along the pre-split-CFG true branch, then the new use will 1.371 +// be from the post-split-CFG true merge point. Vice-versa for the false 1.372 +// path. Some uses will be along both paths; then we sink the use to the 1.373 +// post-dominating location; we may need to insert a Phi there. 1.374 +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 ) { 1.375 + 1.376 + Node *use_blk = find_use_block(use,def,old_false,new_false,old_true,new_true); 1.377 + if( !use_blk ) return; // He's dead, Jim 1.378 + 1.379 + // Walk up the dominator tree until I hit either the old IfFalse, the old 1.380 + // IfTrue or the old If. Insert Phis where needed. 1.381 + Node *new_def = spinup( region_dom, new_false, new_true, use_blk, def, cache ); 1.382 + 1.383 + // Found where this USE goes. Re-point him. 1.384 + uint i; 1.385 + for( i = 0; i < use->req(); i++ ) 1.386 + if( use->in(i) == def ) 1.387 + break; 1.388 + assert( i < use->req(), "def should be among use's inputs" ); 1.389 + _igvn.replace_input_of(use, i, new_def); 1.390 +} 1.391 + 1.392 +//------------------------------do_split_if------------------------------------ 1.393 +// Found an If getting its condition-code input from a Phi in the same block. 1.394 +// Split thru the Region. 1.395 +void PhaseIdealLoop::do_split_if( Node *iff ) { 1.396 +#ifndef PRODUCT 1.397 + if( PrintOpto && VerifyLoopOptimizations ) 1.398 + tty->print_cr("Split-if"); 1.399 + if (TraceLoopOpts) { 1.400 + tty->print_cr("SplitIf"); 1.401 + } 1.402 +#endif 1.403 + C->set_major_progress(); 1.404 + Node *region = iff->in(0); 1.405 + Node *region_dom = idom(region); 1.406 + 1.407 + // We are going to clone this test (and the control flow with it) up through 1.408 + // the incoming merge point. We need to empty the current basic block. 1.409 + // Clone any instructions which must be in this block up through the merge 1.410 + // point. 1.411 + DUIterator i, j; 1.412 + bool progress = true; 1.413 + while (progress) { 1.414 + progress = false; 1.415 + for (i = region->outs(); region->has_out(i); i++) { 1.416 + Node* n = region->out(i); 1.417 + if( n == region ) continue; 1.418 + // The IF to be split is OK. 1.419 + if( n == iff ) continue; 1.420 + if( !n->is_Phi() ) { // Found pinned memory op or such 1.421 + if (split_up(n, region, iff)) { 1.422 + i = region->refresh_out_pos(i); 1.423 + progress = true; 1.424 + } 1.425 + continue; 1.426 + } 1.427 + assert( n->in(0) == region, "" ); 1.428 + 1.429 + // Recursively split up all users of a Phi 1.430 + for (j = n->outs(); n->has_out(j); j++) { 1.431 + Node* m = n->out(j); 1.432 + // If m is dead, throw it away, and declare progress 1.433 + if (_nodes[m->_idx] == NULL) { 1.434 + _igvn.remove_dead_node(m); 1.435 + // fall through 1.436 + } 1.437 + else if (m != iff && split_up(m, region, iff)) { 1.438 + // fall through 1.439 + } else { 1.440 + continue; 1.441 + } 1.442 + // Something unpredictable changed. 1.443 + // Tell the iterators to refresh themselves, and rerun the loop. 1.444 + i = region->refresh_out_pos(i); 1.445 + j = region->refresh_out_pos(j); 1.446 + progress = true; 1.447 + } 1.448 + } 1.449 + } 1.450 + 1.451 + // Now we have no instructions in the block containing the IF. 1.452 + // Split the IF. 1.453 + Node *new_iff = split_thru_region( iff, region ); 1.454 + 1.455 + // Replace both uses of 'new_iff' with Regions merging True/False 1.456 + // paths. This makes 'new_iff' go dead. 1.457 + Node *old_false, *old_true; 1.458 + Node *new_false, *new_true; 1.459 + for (DUIterator_Last j2min, j2 = iff->last_outs(j2min); j2 >= j2min; --j2) { 1.460 + Node *ifp = iff->last_out(j2); 1.461 + assert( ifp->Opcode() == Op_IfFalse || ifp->Opcode() == Op_IfTrue, "" ); 1.462 + ifp->set_req(0, new_iff); 1.463 + Node *ifpx = split_thru_region( ifp, region ); 1.464 + 1.465 + // Replace 'If' projection of a Region with a Region of 1.466 + // 'If' projections. 1.467 + ifpx->set_req(0, ifpx); // A TRUE RegionNode 1.468 + 1.469 + // Setup dominator info 1.470 + set_idom(ifpx, region_dom, dom_depth(region_dom) + 1); 1.471 + 1.472 + // Check for splitting loop tails 1.473 + if( get_loop(iff)->tail() == ifp ) 1.474 + get_loop(iff)->_tail = ifpx; 1.475 + 1.476 + // Replace in the graph with lazy-update mechanism 1.477 + new_iff->set_req(0, new_iff); // hook self so it does not go dead 1.478 + lazy_replace_proj( ifp, ifpx ); 1.479 + new_iff->set_req(0, region); 1.480 + 1.481 + // Record bits for later xforms 1.482 + if( ifp->Opcode() == Op_IfFalse ) { 1.483 + old_false = ifp; 1.484 + new_false = ifpx; 1.485 + } else { 1.486 + old_true = ifp; 1.487 + new_true = ifpx; 1.488 + } 1.489 + } 1.490 + _igvn.remove_dead_node(new_iff); 1.491 + // Lazy replace IDOM info with the region's dominator 1.492 + lazy_replace( iff, region_dom ); 1.493 + 1.494 + // Now make the original merge point go dead, by handling all its uses. 1.495 + small_cache region_cache; 1.496 + // Preload some control flow in region-cache 1.497 + region_cache.lru_insert( new_false, new_false ); 1.498 + region_cache.lru_insert( new_true , new_true ); 1.499 + // Now handle all uses of the splitting block 1.500 + for (DUIterator k = region->outs(); region->has_out(k); k++) { 1.501 + Node* phi = region->out(k); 1.502 + if (!phi->in(0)) { // Dead phi? Remove it 1.503 + _igvn.remove_dead_node(phi); 1.504 + } else if (phi == region) { // Found the self-reference 1.505 + continue; // No roll-back of DUIterator 1.506 + } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region 1.507 + assert(phi->in(0) == region, "Inconsistent graph"); 1.508 + // Need a per-def cache. Phi represents a def, so make a cache 1.509 + small_cache phi_cache; 1.510 + 1.511 + // Inspect all Phi uses to make the Phi go dead 1.512 + for (DUIterator_Last lmin, l = phi->last_outs(lmin); l >= lmin; --l) { 1.513 + Node* use = phi->last_out(l); 1.514 + // Compute the new DEF for this USE. New DEF depends on the path 1.515 + // taken from the original DEF to the USE. The new DEF may be some 1.516 + // collection of PHI's merging values from different paths. The Phis 1.517 + // inserted depend only on the location of the USE. We use a 1.518 + // 2-element cache to handle multiple uses from the same block. 1.519 + handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true); 1.520 + } // End of while phi has uses 1.521 + // Remove the dead Phi 1.522 + _igvn.remove_dead_node( phi ); 1.523 + } else { 1.524 + assert(phi->in(0) == region, "Inconsistent graph"); 1.525 + // Random memory op guarded by Region. Compute new DEF for USE. 1.526 + handle_use(phi, region, ®ion_cache, region_dom, new_false, new_true, old_false, old_true); 1.527 + } 1.528 + // Every path above deletes a use of the region, except for the region 1.529 + // self-cycle (which is needed by handle_use calling find_use_block 1.530 + // calling get_ctrl calling get_ctrl_no_update looking for dead 1.531 + // regions). So roll back the DUIterator innards. 1.532 + --k; 1.533 + } // End of while merge point has phis 1.534 + 1.535 + assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region 1.536 + region->set_req(0, NULL); // Break the self-cycle 1.537 + 1.538 + // Any leftover bits in the splitting block must not have depended on local 1.539 + // Phi inputs (these have already been split-up). Hence it's safe to hoist 1.540 + // these guys to the dominating point. 1.541 + lazy_replace( region, region_dom ); 1.542 +#ifndef PRODUCT 1.543 + if( VerifyLoopOptimizations ) verify(); 1.544 +#endif 1.545 +}