Intermediate writes to array slot not eliminated by optimizer

Vitaly Davidovich vitalyd at gmail.com
Tue May 12 00:25:30 UTC 2015


Hi guys,

Suppose we have the following code:

private static final long[] ARR = new long[10];
private static final int ITERATIONS = 500 * 1000 * 1000;


static void loop() {
    int i = ITERATIONS;
    while(--i >= 0) {
         ARR[4] = i;
     }
}

My expectation would be that loop() effectively compiles to:
ARR[4] = 0;
ret;

However, an actual loop is compiled.  This example is a reduction of a
slightly more involved case that I had in mind, but I'm curious if I'm
missing something here.

I tested this with 8u40 and tiered compilation disabled, for what it's
worth.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150511/7febc6c1/attachment.html>


More information about the hotspot-compiler-dev mailing list