Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/opto/split_if.cpp
+++ new/src/share/vm/opto/split_if.cpp
1 1 /*
2 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #include "precompiled.hpp"
26 26 #include "memory/allocation.inline.hpp"
27 27 #include "opto/callnode.hpp"
28 28 #include "opto/connode.hpp"
29 29 #include "opto/loopnode.hpp"
30 30
31 31
32 32 //------------------------------split_thru_region------------------------------
33 33 // Split Node 'n' through merge point.
34 34 Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) {
35 35 uint wins = 0;
36 36 assert( n->is_CFG(), "" );
37 37 assert( region->is_Region(), "" );
38 38 Node *r = new (C, region->req()) RegionNode( region->req() );
39 39 IdealLoopTree *loop = get_loop( n );
40 40 for( uint i = 1; i < region->req(); i++ ) {
41 41 Node *x = n->clone();
42 42 Node *in0 = n->in(0);
43 43 if( in0->in(0) == region ) x->set_req( 0, in0->in(i) );
44 44 for( uint j = 1; j < n->req(); j++ ) {
45 45 Node *in = n->in(j);
46 46 if( get_ctrl(in) == region )
47 47 x->set_req( j, in->in(i) );
48 48 }
49 49 _igvn.register_new_node_with_optimizer(x);
50 50 set_loop(x, loop);
51 51 set_idom(x, x->in(0), dom_depth(x->in(0))+1);
52 52 r->init_req(i, x);
53 53 }
54 54
55 55 // Record region
56 56 r->set_req(0,region); // Not a TRUE RegionNode
57 57 _igvn.register_new_node_with_optimizer(r);
58 58 set_loop(r, loop);
59 59 if( !loop->_child )
60 60 loop->_body.push(r);
61 61 return r;
62 62 }
63 63
64 64 //------------------------------split_up---------------------------------------
65 65 // Split block-local op up through the phis to empty the current block
66 66 bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) {
67 67 if( n->is_CFG() ) {
68 68 assert( n->in(0) != blk1, "Lousy candidate for split-if" );
69 69 return false;
70 70 }
71 71 if( get_ctrl(n) != blk1 && get_ctrl(n) != blk2 )
72 72 return false; // Not block local
73 73 if( n->is_Phi() ) return false; // Local PHIs are expected
74 74
75 75 // Recursively split-up inputs
76 76 for (uint i = 1; i < n->req(); i++) {
77 77 if( split_up( n->in(i), blk1, blk2 ) ) {
78 78 // Got split recursively and self went dead?
79 79 if (n->outcnt() == 0)
80 80 _igvn.remove_dead_node(n);
81 81 return true;
82 82 }
83 83 }
84 84
85 85 // Check for needing to clone-up a compare. Can't do that, it forces
86 86 // another (nested) split-if transform. Instead, clone it "down".
87 87 if( n->is_Cmp() ) {
88 88 assert(get_ctrl(n) == blk2 || get_ctrl(n) == blk1, "must be in block with IF");
89 89 // Check for simple Cmp/Bool/CMove which we can clone-up. Cmp/Bool/CMove
90 90 // sequence can have no other users and it must all reside in the split-if
91 91 // block. Non-simple Cmp/Bool/CMove sequences are 'cloned-down' below -
92 92 // private, per-use versions of the Cmp and Bool are made. These sink to
93 93 // the CMove block. If the CMove is in the split-if block, then in the
94 94 // next iteration this will become a simple Cmp/Bool/CMove set to clone-up.
95 95 Node *bol, *cmov;
96 96 if( !(n->outcnt() == 1 && n->unique_out()->is_Bool() &&
97 97 (bol = n->unique_out()->as_Bool()) &&
98 98 (get_ctrl(bol) == blk1 ||
99 99 get_ctrl(bol) == blk2) &&
100 100 bol->outcnt() == 1 &&
101 101 bol->unique_out()->is_CMove() &&
102 102 (cmov = bol->unique_out()->as_CMove()) &&
103 103 (get_ctrl(cmov) == blk1 ||
104 104 get_ctrl(cmov) == blk2) ) ) {
105 105
106 106 // Must clone down
107 107 #ifndef PRODUCT
108 108 if( PrintOpto && VerifyLoopOptimizations ) {
109 109 tty->print("Cloning down: ");
110 110 n->dump();
111 111 }
112 112 #endif
113 113 // Clone down any block-local BoolNode uses of this CmpNode
114 114 for (DUIterator i = n->outs(); n->has_out(i); i++) {
115 115 Node* bol = n->out(i);
116 116 assert( bol->is_Bool(), "" );
117 117 if (bol->outcnt() == 1) {
118 118 Node* use = bol->unique_out();
119 119 Node *use_c = use->is_If() ? use->in(0) : get_ctrl(use);
120 120 if (use_c == blk1 || use_c == blk2) {
121 121 continue;
122 122 }
123 123 }
124 124 if (get_ctrl(bol) == blk1 || get_ctrl(bol) == blk2) {
125 125 // Recursively sink any BoolNode
126 126 #ifndef PRODUCT
127 127 if( PrintOpto && VerifyLoopOptimizations ) {
128 128 tty->print("Cloning down: ");
129 129 bol->dump();
130 130 }
131 131 #endif
132 132 for (DUIterator_Last jmin, j = bol->last_outs(jmin); j >= jmin; --j) {
133 133 // Uses are either IfNodes or CMoves
134 134 Node* iff = bol->last_out(j);
135 135 assert( iff->in(1) == bol, "" );
136 136 // Get control block of either the CMove or the If input
137 137 Node *iff_ctrl = iff->is_If() ? iff->in(0) : get_ctrl(iff);
138 138 Node *x = bol->clone();
139 139 register_new_node(x, iff_ctrl);
140 140 _igvn.hash_delete(iff);
141 141 iff->set_req(1, x);
142 142 _igvn._worklist.push(iff);
143 143 }
144 144 _igvn.remove_dead_node( bol );
145 145 --i;
146 146 }
147 147 }
148 148 // Clone down this CmpNode
149 149 for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin; --j) {
150 150 Node* bol = n->last_out(j);
151 151 assert( bol->in(1) == n, "" );
152 152 Node *x = n->clone();
153 153 register_new_node(x, get_ctrl(bol));
154 154 _igvn.hash_delete(bol);
155 155 bol->set_req(1, x);
156 156 _igvn._worklist.push(bol);
157 157 }
158 158 _igvn.remove_dead_node( n );
159 159
160 160 return true;
161 161 }
162 162 }
163 163
164 164 // See if splitting-up a Store. Any anti-dep loads must go up as
165 165 // well. An anti-dep load might be in the wrong block, because in
166 166 // this particular layout/schedule we ignored anti-deps and allow
167 167 // memory to be alive twice. This only works if we do the same
168 168 // operations on anti-dep loads as we do their killing stores.
169 169 if( n->is_Store() && n->in(MemNode::Memory)->in(0) == n->in(0) ) {
170 170 // Get store's memory slice
171 171 int alias_idx = C->get_alias_index(_igvn.type(n->in(MemNode::Address))->is_ptr());
172 172
173 173 // Get memory-phi anti-dep loads will be using
174 174 Node *memphi = n->in(MemNode::Memory);
175 175 assert( memphi->is_Phi(), "" );
176 176 // Hoist any anti-dep load to the splitting block;
177 177 // it will then "split-up".
178 178 for (DUIterator_Fast imax,i = memphi->fast_outs(imax); i < imax; i++) {
179 179 Node *load = memphi->fast_out(i);
180 180 if( load->is_Load() && alias_idx == C->get_alias_index(_igvn.type(load->in(MemNode::Address))->is_ptr()) )
181 181 set_ctrl(load,blk1);
182 182 }
183 183 }
184 184
185 185 // Found some other Node; must clone it up
186 186 #ifndef PRODUCT
187 187 if( PrintOpto && VerifyLoopOptimizations ) {
188 188 tty->print("Cloning up: ");
189 189 n->dump();
190 190 }
191 191 #endif
192 192
193 193 // ConvI2L may have type information on it which becomes invalid if
194 194 // it moves up in the graph so change any clones so widen the type
195 195 // to TypeLong::INT when pushing it up.
196 196 const Type* rtype = NULL;
197 197 if (n->Opcode() == Op_ConvI2L && n->bottom_type() != TypeLong::INT) {
198 198 rtype = TypeLong::INT;
199 199 }
200 200
201 201 // Now actually split-up this guy. One copy per control path merging.
202 202 Node *phi = PhiNode::make_blank(blk1, n);
203 203 for( uint j = 1; j < blk1->req(); j++ ) {
204 204 Node *x = n->clone();
205 205 // Widen the type of the ConvI2L when pushing up.
206 206 if (rtype != NULL) x->as_Type()->set_type(rtype);
207 207 if( n->in(0) && n->in(0) == blk1 )
208 208 x->set_req( 0, blk1->in(j) );
209 209 for( uint i = 1; i < n->req(); i++ ) {
210 210 Node *m = n->in(i);
211 211 if( get_ctrl(m) == blk1 ) {
212 212 assert( m->in(0) == blk1, "" );
213 213 x->set_req( i, m->in(j) );
214 214 }
215 215 }
216 216 register_new_node( x, blk1->in(j) );
217 217 phi->init_req( j, x );
218 218 }
219 219 // Announce phi to optimizer
220 220 register_new_node(phi, blk1);
221 221
222 222 // Remove cloned-up value from optimizer; use phi instead
223 223 _igvn.replace_node( n, phi );
224 224
225 225 // (There used to be a self-recursive call to split_up() here,
226 226 // but it is not needed. All necessary forward walking is done
227 227 // by do_split_if() below.)
228 228
229 229 return true;
230 230 }
231 231
232 232 //------------------------------register_new_node------------------------------
233 233 void PhaseIdealLoop::register_new_node( Node *n, Node *blk ) {
234 234 assert(!n->is_CFG(), "must be data node");
235 235 _igvn.register_new_node_with_optimizer(n);
236 236 set_ctrl(n, blk);
237 237 IdealLoopTree *loop = get_loop(blk);
238 238 if( !loop->_child )
239 239 loop->_body.push(n);
240 240 }
241 241
242 242 //------------------------------small_cache------------------------------------
243 243 struct small_cache : public Dict {
244 244
245 245 small_cache() : Dict( cmpkey, hashptr ) {}
246 246 Node *probe( Node *use_blk ) { return (Node*)((*this)[use_blk]); }
247 247 void lru_insert( Node *use_blk, Node *new_def ) { Insert(use_blk,new_def); }
248 248 };
249 249
250 250 //------------------------------spinup-----------------------------------------
251 251 // "Spin up" the dominator tree, starting at the use site and stopping when we
252 252 // find the post-dominating point.
253 253
254 254 // We must be at the merge point which post-dominates 'new_false' and
255 255 // 'new_true'. Figure out which edges into the RegionNode eventually lead up
256 256 // to false and which to true. Put in a PhiNode to merge values; plug in
257 257 // the appropriate false-arm or true-arm values. If some path leads to the
258 258 // original IF, then insert a Phi recursively.
259 259 Node *PhaseIdealLoop::spinup( Node *iff_dom, Node *new_false, Node *new_true, Node *use_blk, Node *def, small_cache *cache ) {
260 260 if (use_blk->is_top()) // Handle dead uses
261 261 return use_blk;
262 262 Node *prior_n = (Node*)0xdeadbeef;
263 263 Node *n = use_blk; // Get path input
264 264 assert( use_blk != iff_dom, "" );
265 265 // Here's the "spinup" the dominator tree loop. Do a cache-check
266 266 // along the way, in case we've come this way before.
267 267 while( n != iff_dom ) { // Found post-dominating point?
268 268 prior_n = n;
269 269 n = idom(n); // Search higher
270 270 Node *s = cache->probe( prior_n ); // Check cache
271 271 if( s ) return s; // Cache hit!
272 272 }
273 273
274 274 Node *phi_post;
275 275 if( prior_n == new_false || prior_n == new_true ) {
276 276 phi_post = def->clone();
277 277 phi_post->set_req(0, prior_n );
278 278 register_new_node(phi_post, prior_n);
279 279 } else {
280 280 // This method handles both control uses (looking for Regions) or data
281 281 // uses (looking for Phis). If looking for a control use, then we need
282 282 // to insert a Region instead of a Phi; however Regions always exist
283 283 // previously (the hash_find_insert below would always hit) so we can
284 284 // return the existing Region.
285 285 if( def->is_CFG() ) {
286 286 phi_post = prior_n; // If looking for CFG, return prior
287 287 } else {
288 288 assert( def->is_Phi(), "" );
289 289 assert( prior_n->is_Region(), "must be a post-dominating merge point" );
290 290
291 291 // Need a Phi here
292 292 phi_post = PhiNode::make_blank(prior_n, def);
293 293 // Search for both true and false on all paths till find one.
294 294 for( uint i = 1; i < phi_post->req(); i++ ) // For all paths
295 295 phi_post->init_req( i, spinup( iff_dom, new_false, new_true, prior_n->in(i), def, cache ) );
296 296 Node *t = _igvn.hash_find_insert(phi_post);
297 297 if( t ) { // See if we already have this one
298 298 // phi_post will not be used, so kill it
299 299 _igvn.remove_dead_node(phi_post);
300 300 phi_post->destruct();
301 301 phi_post = t;
302 302 } else {
303 303 register_new_node( phi_post, prior_n );
304 304 }
305 305 }
306 306 }
307 307
308 308 // Update cache everywhere
309 309 prior_n = (Node*)0xdeadbeef; // Reset IDOM walk
310 310 n = use_blk; // Get path input
311 311 // Spin-up the idom tree again, basically doing path-compression.
312 312 // Insert cache entries along the way, so that if we ever hit this
313 313 // point in the IDOM tree again we'll stop immediately on a cache hit.
314 314 while( n != iff_dom ) { // Found post-dominating point?
315 315 prior_n = n;
316 316 n = idom(n); // Search higher
317 317 cache->lru_insert( prior_n, phi_post ); // Fill cache
318 318 } // End of while not gone high enough
319 319
320 320 return phi_post;
321 321 }
322 322
323 323 //------------------------------find_use_block---------------------------------
324 324 // Find the block a USE is in. Normally USE's are in the same block as the
325 325 // using instruction. For Phi-USE's, the USE is in the predecessor block
326 326 // along the corresponding path.
327 327 Node *PhaseIdealLoop::find_use_block( Node *use, Node *def, Node *old_false, Node *new_false, Node *old_true, Node *new_true ) {
328 328 // CFG uses are their own block
329 329 if( use->is_CFG() )
330 330 return use;
331 331
332 332 if( use->is_Phi() ) { // Phi uses in prior block
333 333 // Grab the first Phi use; there may be many.
334 334 // Each will be handled as a separate iteration of
335 335 // the "while( phi->outcnt() )" loop.
336 336 uint j;
337 337 for( j = 1; j < use->req(); j++ )
338 338 if( use->in(j) == def )
339 339 break;
340 340 assert( j < use->req(), "def should be among use's inputs" );
341 341 return use->in(0)->in(j);
342 342 }
343 343 // Normal (non-phi) use
344 344 Node *use_blk = get_ctrl(use);
345 345 // Some uses are directly attached to the old (and going away)
346 346 // false and true branches.
347 347 if( use_blk == old_false ) {
348 348 use_blk = new_false;
349 349 set_ctrl(use, new_false);
350 350 }
351 351 if( use_blk == old_true ) {
352 352 use_blk = new_true;
353 353 set_ctrl(use, new_true);
354 354 }
355 355
356 356 if (use_blk == NULL) { // He's dead, Jim
357 357 _igvn.replace_node(use, C->top());
358 358 }
359 359
360 360 return use_blk;
361 361 }
362 362
363 363 //------------------------------handle_use-------------------------------------
364 364 // Handle uses of the merge point. Basically, split-if makes the merge point
365 365 // go away so all uses of the merge point must go away as well. Most block
366 366 // local uses have already been split-up, through the merge point. Uses from
367 367 // far below the merge point can't always be split up (e.g., phi-uses are
368 368 // pinned) and it makes too much stuff live. Instead we use a path-based
369 369 // solution to move uses down.
370 370 //
371 371 // If the use is along the pre-split-CFG true branch, then the new use will
372 372 // be from the post-split-CFG true merge point. Vice-versa for the false
373 373 // path. Some uses will be along both paths; then we sink the use to the
374 374 // post-dominating location; we may need to insert a Phi there.
375 375 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 ) {
376 376
377 377 Node *use_blk = find_use_block(use,def,old_false,new_false,old_true,new_true);
378 378 if( !use_blk ) return; // He's dead, Jim
379 379
380 380 // Walk up the dominator tree until I hit either the old IfFalse, the old
381 381 // IfTrue or the old If. Insert Phis where needed.
382 382 Node *new_def = spinup( region_dom, new_false, new_true, use_blk, def, cache );
383 383
384 384 // Found where this USE goes. Re-point him.
385 385 uint i;
386 386 for( i = 0; i < use->req(); i++ )
387 387 if( use->in(i) == def )
388 388 break;
389 389 assert( i < use->req(), "def should be among use's inputs" );
390 390 _igvn.hash_delete(use);
391 391 use->set_req(i, new_def);
392 392 _igvn._worklist.push(use);
393 393 }
394 394
395 395 //------------------------------do_split_if------------------------------------
396 396 // Found an If getting its condition-code input from a Phi in the same block.
397 397 // Split thru the Region.
398 398 void PhaseIdealLoop::do_split_if( Node *iff ) {
399 399 #ifndef PRODUCT
400 400 if( PrintOpto && VerifyLoopOptimizations )
401 401 tty->print_cr("Split-if");
402 402 if (TraceLoopOpts) {
403 403 tty->print_cr("SplitIf");
404 404 }
405 405 #endif
406 406 C->set_major_progress();
407 407 Node *region = iff->in(0);
408 408 Node *region_dom = idom(region);
409 409
410 410 // We are going to clone this test (and the control flow with it) up through
411 411 // the incoming merge point. We need to empty the current basic block.
412 412 // Clone any instructions which must be in this block up through the merge
413 413 // point.
414 414 DUIterator i, j;
415 415 bool progress = true;
416 416 while (progress) {
417 417 progress = false;
418 418 for (i = region->outs(); region->has_out(i); i++) {
419 419 Node* n = region->out(i);
420 420 if( n == region ) continue;
421 421 // The IF to be split is OK.
422 422 if( n == iff ) continue;
423 423 if( !n->is_Phi() ) { // Found pinned memory op or such
424 424 if (split_up(n, region, iff)) {
425 425 i = region->refresh_out_pos(i);
426 426 progress = true;
427 427 }
428 428 continue;
429 429 }
430 430 assert( n->in(0) == region, "" );
431 431
432 432 // Recursively split up all users of a Phi
433 433 for (j = n->outs(); n->has_out(j); j++) {
434 434 Node* m = n->out(j);
435 435 // If m is dead, throw it away, and declare progress
436 436 if (_nodes[m->_idx] == NULL) {
437 437 _igvn.remove_dead_node(m);
438 438 // fall through
439 439 }
440 440 else if (m != iff && split_up(m, region, iff)) {
441 441 // fall through
442 442 } else {
443 443 continue;
444 444 }
445 445 // Something unpredictable changed.
446 446 // Tell the iterators to refresh themselves, and rerun the loop.
447 447 i = region->refresh_out_pos(i);
448 448 j = region->refresh_out_pos(j);
449 449 progress = true;
450 450 }
451 451 }
452 452 }
453 453
454 454 // Now we have no instructions in the block containing the IF.
455 455 // Split the IF.
456 456 Node *new_iff = split_thru_region( iff, region );
457 457
458 458 // Replace both uses of 'new_iff' with Regions merging True/False
459 459 // paths. This makes 'new_iff' go dead.
460 460 Node *old_false, *old_true;
461 461 Node *new_false, *new_true;
462 462 for (DUIterator_Last j2min, j2 = iff->last_outs(j2min); j2 >= j2min; --j2) {
463 463 Node *ifp = iff->last_out(j2);
464 464 assert( ifp->Opcode() == Op_IfFalse || ifp->Opcode() == Op_IfTrue, "" );
465 465 ifp->set_req(0, new_iff);
466 466 Node *ifpx = split_thru_region( ifp, region );
467 467
468 468 // Replace 'If' projection of a Region with a Region of
469 469 // 'If' projections.
470 470 ifpx->set_req(0, ifpx); // A TRUE RegionNode
471 471
472 472 // Setup dominator info
473 473 set_idom(ifpx, region_dom, dom_depth(region_dom) + 1);
474 474
475 475 // Check for splitting loop tails
476 476 if( get_loop(iff)->tail() == ifp )
477 477 get_loop(iff)->_tail = ifpx;
478 478
479 479 // Replace in the graph with lazy-update mechanism
480 480 new_iff->set_req(0, new_iff); // hook self so it does not go dead
481 481 lazy_replace_proj( ifp, ifpx );
482 482 new_iff->set_req(0, region);
483 483
484 484 // Record bits for later xforms
485 485 if( ifp->Opcode() == Op_IfFalse ) {
486 486 old_false = ifp;
487 487 new_false = ifpx;
488 488 } else {
489 489 old_true = ifp;
490 490 new_true = ifpx;
491 491 }
492 492 }
↓ open down ↓ |
492 lines elided |
↑ open up ↑ |
493 493 _igvn.remove_dead_node(new_iff);
494 494 // Lazy replace IDOM info with the region's dominator
495 495 lazy_replace( iff, region_dom );
496 496
497 497 // Now make the original merge point go dead, by handling all its uses.
498 498 small_cache region_cache;
499 499 // Preload some control flow in region-cache
500 500 region_cache.lru_insert( new_false, new_false );
501 501 region_cache.lru_insert( new_true , new_true );
502 502 // Now handle all uses of the splitting block
503 - for (DUIterator_Last kmin, k = region->last_outs(kmin); k >= kmin; --k) {
504 - Node* phi = region->last_out(k);
505 - if( !phi->in(0) ) { // Dead phi? Remove it
503 + for (DUIterator k = region->outs(); region->has_out(k); k++) {
504 + Node* phi = region->out(k);
505 + if (!phi->in(0)) { // Dead phi? Remove it
506 506 _igvn.remove_dead_node(phi);
507 - continue;
508 - }
509 - assert( phi->in(0) == region, "" );
510 - if( phi == region ) { // Found the self-reference
511 - phi->set_req(0, NULL);
512 - continue; // Break the self-cycle
513 - }
514 - // Expected common case: Phi hanging off of Region
515 - if( phi->is_Phi() ) {
507 + } else if (phi == region) { // Found the self-reference
508 + continue; // No roll-back of DUIterator
509 + } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
510 + assert(phi->in(0) == region, "Inconsistent graph");
516 511 // Need a per-def cache. Phi represents a def, so make a cache
517 512 small_cache phi_cache;
518 513
519 514 // Inspect all Phi uses to make the Phi go dead
520 515 for (DUIterator_Last lmin, l = phi->last_outs(lmin); l >= lmin; --l) {
521 516 Node* use = phi->last_out(l);
522 517 // Compute the new DEF for this USE. New DEF depends on the path
523 518 // taken from the original DEF to the USE. The new DEF may be some
524 519 // collection of PHI's merging values from different paths. The Phis
525 520 // inserted depend only on the location of the USE. We use a
526 521 // 2-element cache to handle multiple uses from the same block.
527 - handle_use( use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true );
522 + handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
528 523 } // End of while phi has uses
529 -
530 - // Because handle_use might relocate region->_out,
531 - // we must refresh the iterator.
532 - k = region->last_outs(kmin);
533 -
534 524 // Remove the dead Phi
535 525 _igvn.remove_dead_node( phi );
536 -
537 526 } else {
527 + assert(phi->in(0) == region, "Inconsistent graph");
538 528 // Random memory op guarded by Region. Compute new DEF for USE.
539 - handle_use( phi, region, ®ion_cache, region_dom, new_false, new_true, old_false, old_true );
529 + handle_use(phi, region, ®ion_cache, region_dom, new_false, new_true, old_false, old_true);
540 530 }
541 -
531 + // Every path above deletes a use of the region, except for the region
532 + // self-cycle (which is needed by handle_use calling find_use_block
533 + // calling get_ctrl calling get_ctrl_no_update looking for dead
534 + // regions). So roll back the DUIterator innards.
535 + --k;
542 536 } // End of while merge point has phis
543 537
538 + assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
539 + region->set_req(0, NULL); // Break the self-cycle
540 +
544 541 // Any leftover bits in the splitting block must not have depended on local
545 542 // Phi inputs (these have already been split-up). Hence it's safe to hoist
546 543 // these guys to the dominating point.
547 544 lazy_replace( region, region_dom );
548 545 #ifndef PRODUCT
549 546 if( VerifyLoopOptimizations ) verify();
550 547 #endif
551 548 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX