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

C2: int counted loop with long limit not recognized as counted loop

XMLWordPrintable

      This came up with the memory segment API:

              int sum = 0;
              for (int i = 0; i < segment.byteSize(); i++) {
                  sum += segment.get(JAVA_BYTE, i);
              }
      is not recognize as counted loop because segment.byteSize() is a long and the comparison really is:

      (long)i < segment.byteSize()

      We'd like this to be converted to:

      i < (int)segment.byteSize()

      which is only possible if segment.byteSize() fits an int.

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

              Created:
              Updated: