JDK-8080289 : Intermediate writes in a loop not eliminated by optimizer
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-05-13
  • Updated: 2018-05-31
  • Resolved: 2015-08-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b81Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
From Vitaly Davidovich:

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.