RFR: 8271118: C2: StressGCM should have higher priority than frequency-based policy

Yi Yang yyang at openjdk.java.net
Thu Jul 22 05:54:48 UTC 2021


On Thu, 22 Jul 2021 05:34:40 GMT, Yi Yang <yyang at openjdk.org> wrote:

> I think StressGCM should have higher priority than frequency-based policy, otherwise StressGCM has no chance to choose because the frequency-based policy would choose block first if appropriately.

src/hotspot/share/opto/gcm.cpp line 1210:

> 1208:     cand_cnt++;
> 1209:     if ((StressGCM && C->randomized_select(cand_cnt)) ||  // Should be randomly accepted in stress mode
> 1210:         LCA_freq < least_freq           ||    // Better Frequency

Should we break once StressGCM chooses a block? Looks like:

    cand_cnt++;
    bool use_random_block = StressGCM && C->randomized_select(cand_cnt);
    if (use_random_block ||  // Should be randomly accepted in stress mode
        LCA_freq < least_freq           ||    // Better Frequency
         (!StressGCM                    &&    // Otherwise, choose with latency
          !in_latency                   &&    // No block containing latency
          LCA_freq < least_freq * delta &&    // No worse frequency
          target >= end_lat             &&    // within latency range
          !self->is_iteratively_computed() )  // But don't hoist IV increments
             // because they may end up above other uses of their phi forcing
             // their result register to be different from their input.
       ) {
      least = LCA;            // Found cheaper block
      least_freq = LCA_freq;
      start_latency = start_lat;
      end_latency = end_lat;
      if (target <= start_lat)
        in_latency = true;
      if (use_random_block) {
        break;
      }
    }
  }

-------------

PR: https://git.openjdk.java.net/jdk/pull/4865


More information about the hotspot-compiler-dev mailing list