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

Intermediate writes in a loop not eliminated by optimizer

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • b81

        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.

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

                Created:
                Updated:
                Resolved: