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

Fix post loop vectorization with parallel loop iv

XMLWordPrintable

    • generic
    • generic

      Recently we find HotSpot jtreg test/hotspot/jtreg/compiler/vectorization/runner/LoopLiveOutNodesTest.java fails intermittently on Arm Neoverse-N2 (a kind of AArch64 CPU with 128-bit Scalable Vector Extension). After some investigation, we find it's caused by a bug in the experimental post loop vectorization with parallel loop induction variables. We create below test case to stably reproduce the issue.

      public class Foo {
          private static final int SIZE = 500;

          private static int[] a = new int[SIZE];
          private static int[] b = new int[SIZE];

          private static int init = 33;
          private static int iters = 335;

          private static int testLoop(int start, int end) {
              int i = 0, j = 0;
              for (i = start; i < end; i++, j++) {
                  b[i] = a[i];
              }
              return j;
          }

          public static void main(String[] args) {
              // Warmup
              for (int warmup = 0; warmup < 20000; warmup++) {
                  testLoop(0, 500);
              }
              // Test
              int result = testLoop(init, init + iters);
              if (result != iters) {
                  throw new RuntimeException("Incorrect result: expected = " +
                          iters + ", actual = " + result);
              }
              System.out.println("Passed");
          }
      }

      $ java Foo
      Passed

      $ java -XX:+UnlockExperimentalVMOptions -XX:+PostLoopMultiversioning Foo
      Exception in thread "main" java.lang.RuntimeException: Incorrect result: expected = 335, actual = 328
      at Foo.main(Foo.java:26)

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

              Created:
              Updated:
              Resolved: