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

C2 SuperWord: improve PopulateIndex detection for L/F/D

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 23
    • hotspot

      By accident, I discovered that PopulateIndex does not work very well with L/F/D. I added these lines to
      /oracle-work/jdk-fork2/open/test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java

      The culprit is that we split the ConvI2L/D/F through the AddI, at least in some cases of the pack, and that confuses the packing logic. If init/limit are variable, the split cannot happen, and it vectorizes.

      Not sure if this can be fixed, or is worth fixing.

          @Test
          @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
              counts = {IRNode.POPULATE_INDEX, "=0"})
          // The ConvI2L can be split through the AddI, creating a mix of
          // ConvI2L(AddI) and AddL(ConvI2L) cases, which do not vectorize.
          public long[] fillLongArray() {
              long[] res = new long[SIZE];
              for (int i = 0; i < SIZE; i++) {
                  res[i] = i;
              }
              return res;
          }
                                                                                                                                                                                                    
          @Test
          @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
              counts = {IRNode.POPULATE_INDEX, ">0"})
          // The variable init/limit has the consequence that we do not split
          // the ConvI2L through the AddI.
          public long[] fillLongArray2() {
              long[] res = new long[SIZE];
              for (int i = init; i < limit; i++) {
                  res[i] = i;
              }
              return res;
          }
                                                                                                                                                                                                    
          @Test
          @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
              counts = {IRNode.POPULATE_INDEX, "=0"})
          public float[] fillFloatArray() {
              float[] res = new float[SIZE];
              for (int i = 0; i < SIZE; i++) {
                  res[i] = i;
              }
              return res;
          }
                                                                                                                                                                                                    
          @Test
          @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
              counts = {IRNode.POPULATE_INDEX, ">0"})
          public float[] fillFloatArray2() {
              float[] res = new float[SIZE];
              for (int i = init; i < limit; i++) {
                  res[i] = i;
              }
              return res;
          }
                                                                                                                                                                                                    
          @Test
          @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
              counts = {IRNode.POPULATE_INDEX, "=0"})
          public double[] fillDoubleArray() {
              double[] res = new double[SIZE];
              for (int i = 0; i < SIZE; i++) {
                  res[i] = i;
              }
              return res;
          }
                                                                                                                                                                                                    
          @Test
          @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
              counts = {IRNode.POPULATE_INDEX, ">0"})
          public double[] fillDoubleArray2() {
              double[] res = new double[SIZE];
              for (int i = init; i < limit; i++) {
                  res[i] = i;
              }
              return res;
          }

            epeter Emanuel Peter
            epeter Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: