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

C2 should optimize long accumulations in a counted loop

XMLWordPrintable

      In:

      public static long testLongAcc() {
         long acc = 0;

         for (int i = 0; i < 1000; i++) {
             acc += 8;
         }

         return acc;
      }

      C2 doesn't optimize the loop out while in:

      public static long testIntAcc() {
         int acc = 0;

         for (int i = 0; i < 1000; i++) {
             acc += 8;
         }

         return acc;
      }

      it does

            kxu Kangcheng Xu
            roland Roland Westrelin
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: