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

Incorrect post loop vectorization when IV is converted to long

    XMLWordPrintable

Details

    • x86, aarch64
    • generic

    Description

      Recently we find a defect of post loop vectorization from a fuzzer test. After a few investigation, we created below simple case to reproduce it on CPUs with vector mask support (x86 AVX-512 or AArch64 SVE).

      public class Foo {
        private static int[] a = new int[100];
        private static long val = 0;

        private static void bar() {
          int i = 0;
          for (i = 3; i < 50; i++)
            a[i] += 1;
          val += i;
        }

        public static void main(String[] strArr) {
          bar();
          System.out.println(val);
        }
      }

      $ java Foo
      50

      $ java -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:CompileOnly=Foo.bar -XX:-TieredCompilation -XX:+UnlockExperimentalVMOptions -XX:+PostLoopMultiversioning Foo
      47

      In this case, the induction variable `i` is used after the loop and converted and added to a long. The add uses the ConvI2LNode which is not correctly incremented after loop.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pli Pengfei Li
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: