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

C2: Enable SLP for some manually unrolled loops

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11, 14, 15
    • Fix Version/s: 15
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Introduced In Version:
    • Resolved In Build:
      b26
    • CPU:
      x86, aarch64
    • OS:
      generic

      Description

      (1) Below loop with stride = 1 can be auto-vectorized by the C2 SLP.
        private static void bar(int start, int limit) {
          for (int i = start; i < limit; i += 1) {
            c[i] = a[i] + b[i];
          }
        }

      (2) If we manually unroll it once, like below. C2 SLP fails to vectorize it.
        private static void bar(int start, int limit) {
          for (int i = start; i < limit; i += 2) {
            c[i] = a[i] + b[i];
            c[i + 1] = a[i + 1] + b[i + 1];
          }
        }

      (3) But if we change the loop iv initial value to a compile-time constant, it can be vectorized again.
        private static void bar(int start, int limit) {
          for (int i = 10; i < limit; i += 2) {
            c[i] = a[i] + b[i];
            c[i + 1] = a[i + 1] + b[i + 1];
          }
        }

      We should try to enable the auto-vectorization for above case (2).

        Attachments

          Activity

            People

            • Assignee:
              pli Pengfei Li
              Reporter:
              pli Pengfei Li
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: