src/share/vm/opto/split_if.cpp

changeset 3093
8805f8c1e23e
parent 2727
08eb13460b3a
child 3847
5e990493719e
     1.1 --- a/src/share/vm/opto/split_if.cpp	Fri Aug 26 08:52:22 2011 -0700
     1.2 +++ b/src/share/vm/opto/split_if.cpp	Sat Aug 27 00:23:47 2011 -0700
     1.3 @@ -500,19 +500,14 @@
     1.4    region_cache.lru_insert( new_false, new_false );
     1.5    region_cache.lru_insert( new_true , new_true  );
     1.6    // Now handle all uses of the splitting block
     1.7 -  for (DUIterator_Last kmin, k = region->last_outs(kmin); k >= kmin; --k) {
     1.8 -    Node* phi = region->last_out(k);
     1.9 -    if( !phi->in(0) ) {         // Dead phi?  Remove it
    1.10 +  for (DUIterator k = region->outs(); region->has_out(k); k++) {
    1.11 +    Node* phi = region->out(k);
    1.12 +    if (!phi->in(0)) {         // Dead phi?  Remove it
    1.13        _igvn.remove_dead_node(phi);
    1.14 -      continue;
    1.15 -    }
    1.16 -    assert( phi->in(0) == region, "" );
    1.17 -    if( phi == region ) {       // Found the self-reference
    1.18 -      phi->set_req(0, NULL);
    1.19 -      continue;                 // Break the self-cycle
    1.20 -    }
    1.21 -    // Expected common case: Phi hanging off of Region
    1.22 -    if( phi->is_Phi() ) {
    1.23 +    } else if (phi == region) { // Found the self-reference
    1.24 +      continue;                 // No roll-back of DUIterator
    1.25 +    } else if (phi->is_Phi()) { // Expected common case: Phi hanging off of Region
    1.26 +      assert(phi->in(0) == region, "Inconsistent graph");
    1.27        // Need a per-def cache.  Phi represents a def, so make a cache
    1.28        small_cache phi_cache;
    1.29  
    1.30 @@ -524,22 +519,24 @@
    1.31          // collection of PHI's merging values from different paths.  The Phis
    1.32          // inserted depend only on the location of the USE.  We use a
    1.33          // 2-element cache to handle multiple uses from the same block.
    1.34 -        handle_use( use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true );
    1.35 +        handle_use(use, phi, &phi_cache, region_dom, new_false, new_true, old_false, old_true);
    1.36        } // End of while phi has uses
    1.37 -
    1.38 -      // Because handle_use might relocate region->_out,
    1.39 -      // we must refresh the iterator.
    1.40 -      k = region->last_outs(kmin);
    1.41 -
    1.42        // Remove the dead Phi
    1.43        _igvn.remove_dead_node( phi );
    1.44 +    } else {
    1.45 +      assert(phi->in(0) == region, "Inconsistent graph");
    1.46 +      // Random memory op guarded by Region.  Compute new DEF for USE.
    1.47 +      handle_use(phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true);
    1.48 +    }
    1.49 +    // Every path above deletes a use of the region, except for the region
    1.50 +    // self-cycle (which is needed by handle_use calling find_use_block
    1.51 +    // calling get_ctrl calling get_ctrl_no_update looking for dead
    1.52 +    // regions).  So roll back the DUIterator innards.
    1.53 +    --k;
    1.54 +  } // End of while merge point has phis
    1.55  
    1.56 -    } else {
    1.57 -      // Random memory op guarded by Region.  Compute new DEF for USE.
    1.58 -      handle_use( phi, region, &region_cache, region_dom, new_false, new_true, old_false, old_true );
    1.59 -    }
    1.60 -
    1.61 -  } // End of while merge point has phis
    1.62 +  assert(region->outcnt() == 1, "Only self reference should remain"); // Just Self on the Region
    1.63 +  region->set_req(0, NULL);       // Break the self-cycle
    1.64  
    1.65    // Any leftover bits in the splitting block must not have depended on local
    1.66    // Phi inputs (these have already been split-up).  Hence it's safe to hoist

mercurial