Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8080289

Intermediate writes in a loop not eliminated by optimizer

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b81

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  roland Roland Westrelin
                  Reporter:
                  roland Roland Westrelin
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: