Intermediate writes in a loop not eliminated by optimizer

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 9
    • Affects Version/s: 9
    • Component/s: 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.

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

                Created:
                Updated:
                Resolved: