src/share/vm/opto/loopTransform.cpp

changeset 2880
f879eafd5835
parent 2877
bad7ecd0b6ed
child 2899
3b1d58916d5f
     1.1 --- a/src/share/vm/opto/loopTransform.cpp	Wed May 04 22:41:17 2011 -0700
     1.2 +++ b/src/share/vm/opto/loopTransform.cpp	Thu May 05 21:06:14 2011 -0700
     1.3 @@ -1229,6 +1229,19 @@
     1.4          new_limit = _igvn.intcon(limit->get_int() - stride_con);
     1.5          set_ctrl(new_limit, C->root());
     1.6        } else {
     1.7 +        // Limit is not constant.
     1.8 +        {
     1.9 +          // Separate limit by Opaque node in case it is an incremented
    1.10 +          // variable from previous loop to avoid using pre-incremented
    1.11 +          // value which could increase register pressure.
    1.12 +          // Otherwise reorg_offsets() optimization will create a separate
    1.13 +          // Opaque node for each use of trip-counter and as result
    1.14 +          // zero trip guard limit will be different from loop limit.
    1.15 +          assert(has_ctrl(opaq), "should have it");
    1.16 +          Node* opaq_ctrl = get_ctrl(opaq);
    1.17 +          limit = new (C, 2) Opaque2Node( C, limit );
    1.18 +          register_new_node( limit, opaq_ctrl );
    1.19 +        }
    1.20          if (stride_con > 0 && ((limit_type->_lo - stride_con) < limit_type->_lo) ||
    1.21                     stride_con < 0 && ((limit_type->_hi - stride_con) > limit_type->_hi)) {
    1.22            // No underflow.
    1.23 @@ -1278,24 +1291,19 @@
    1.24          register_new_node(new_limit, ctrl);
    1.25        }
    1.26        assert(new_limit != NULL, "");
    1.27 -      if (limit->outcnt() == 2) {
    1.28 -        // Replace old limit if it is used only in loop tests.
    1.29 -        _igvn.replace_node(limit, new_limit);
    1.30 -      } else {
    1.31 -        // Replace in loop test.
    1.32 -        _igvn.hash_delete(cmp);
    1.33 -        cmp->set_req(2, new_limit);
    1.34 +      // Replace in loop test.
    1.35 +      _igvn.hash_delete(cmp);
    1.36 +      cmp->set_req(2, new_limit);
    1.37  
    1.38 -        // Step 3: Find the min-trip test guaranteed before a 'main' loop.
    1.39 -        // Make it a 1-trip test (means at least 2 trips).
    1.40 +      // Step 3: Find the min-trip test guaranteed before a 'main' loop.
    1.41 +      // Make it a 1-trip test (means at least 2 trips).
    1.42  
    1.43 -        // Guard test uses an 'opaque' node which is not shared.  Hence I
    1.44 -        // can edit it's inputs directly.  Hammer in the new limit for the
    1.45 -        // minimum-trip guard.
    1.46 -        assert(opaq->outcnt() == 1, "");
    1.47 -        _igvn.hash_delete(opaq);
    1.48 -        opaq->set_req(1, new_limit);
    1.49 -      }
    1.50 +      // Guard test uses an 'opaque' node which is not shared.  Hence I
    1.51 +      // can edit it's inputs directly.  Hammer in the new limit for the
    1.52 +      // minimum-trip guard.
    1.53 +      assert(opaq->outcnt() == 1, "");
    1.54 +      _igvn.hash_delete(opaq);
    1.55 +      opaq->set_req(1, new_limit);
    1.56      }
    1.57  
    1.58      // Adjust max trip count. The trip count is intentionally rounded

mercurial