RFR: 8261137: Optimization of Box nodes in uncommon_trap [v2]

Xin Liu xliu at openjdk.java.net
Tue Feb 9 00:33:51 UTC 2021


On Mon, 8 Feb 2021 22:47:43 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> I am a little concern about stretching uses of input value outside scope where it is created (for example, loop's variable or a value depending on it).
>> This optimization may work only because boxed values are immutable.
>> I will run our tests with this changes.
>
> Our tier1-4 testing passed

> I was wandering if we can remove the useless `if` as it's always true in this case. Do you know why this kind of `if` haven't been eliminated by GVN phase?

Eventually, c2 should know that `i < data.length' is true. it should be done by GCP later. 

The example is a special case.  you can remove this " if (i < data.length)"  here.  Generally, target code can look like this. c2 speculatively generates an uncommon_trap of "unstable_if".

  for (int i = 0; i < data.length; i++) {
      Integer ii = Integer.valueOf(data[i]);
      if (cond) { //likely
          sum += ii.intValue();
      }
  }

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

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


More information about the hotspot-compiler-dev mailing list