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

VectorReshapeTests are not effective due to failing to intrinsify "VectorSupport.convert"



    • Subcomponent:
    • Resolved In Build:


      Inlining "VectorSupport.convert()" needs all the arguments are constants, see the check at the begining:
       bool LibraryCallKit::inline_vector_convert() {
            const TypeInt* opr = gvn().type(argument(0))->is_int();

            const TypeInstPtr* vector_klass_from = gvn().type(argument(1))->is_instptr();
            const TypeInstPtr* elem_klass_from = gvn().type(argument(2))->is_instptr();
            const TypeInt* vlen_from = gvn().type(argument(3))->is_int();

            const TypeInstPtr* vector_klass_to = gvn().type(argument(4))->is_instptr();
            const TypeInstPtr* elem_klass_to = gvn().type(argument(5))->is_instptr();
            const TypeInt* vlen_to = gvn().type(argument(6))->is_int();

            if (!opr->is_con() ||
                vector_klass_from->const_oop() == NULL || elem_klass_from->const_oop() == NULL || !vlen_from->is_con() ||
                vector_klass_to->const_oop() == NULL || elem_klass_to->const_oop() == NULL || !vlen_to->is_con()) {
                if (C->print_intrinsics()) {
                    tty->print_cr(" ** missing constant: opr=%s vclass_from=%s etype_from=%s vlen_from=%s vclass_to=%s etype_to=%s vlen_to=%s",
               return false; // not enough info for intrinsification

      These arguments all come from the "VectorSpecies" at the begining of the VectorAPI. To make sure the api can be intrinsifed, the VectorSpecies is needed to be constant as well.

      However, most of the tests in "test/jdk/jdk/incubator/vector/VectorReshapeTests.java" uses the VectorSpecies as the method argument. And they will be used to get the vector type information for "VectorSupport.convert" finally. For example:

          static <E>
          void testVectorReshape(VectorSpecies<E> a, VectorSpecies<E> b, byte[] input, byte[] output) {
              testVectorReshape(a, b, input, output, false);
              testVectorReshapeLanewise(a, b, input, output);
          @Test(dataProvider = "byteUnaryOpProvider")
          static void testReshapeByte(IntFunction<byte[]> fa) {
              byte[] bin64 = fa.apply(64/Byte.SIZE);
              byte[] bin128 = fa.apply(128/Byte.SIZE);
              byte[] bin256 = fa.apply(256/Byte.SIZE);
              byte[] bin512 = fa.apply(512/Byte.SIZE);
              byte[] binMax = fa.apply(S_Max_BIT.vectorBitSize()/Byte.SIZE);
              byte[] bout64 = new byte[bin64.length];
              byte[] bout128 = new byte[bin128.length];
              byte[] bout256 = new byte[bin256.length];
              byte[] bout512 = new byte[bin512.length];
              byte[] boutMax = new byte[binMax.length];

              for (int i = 0; i < NUM_ITER; i++) {
                  testVectorReshape(bspec64, bspec64, bin64, bout64);
                  testVectorReshape(bspec64, bspec128, bin64, bout128);
                  testVectorReshape(bspec64, bspec256, bin64, bout256);
                  testVectorReshape(bspec64, bspec512, bin64, bout512);
                  testVectorReshape(bspec64, bspecMax, bin64, boutMax);


      Even the methods is annotated with "ForceInline", the inline might fail I think. If so, the compiler might not treat the VectorSpecies as a constant, and the "VectorSupport.convert" will fail to be intrinsified and go back to the java implementation. This makes the whole tests non-effective.

      I'v tested it by adding some error in the ad file for cast/reinterpret match rules, and the issues are not reported as expected when running the VectorReshapeTests.java.


          Issue Links



              psandoz Paul Sandoz
              xgong Xiaohong Gong
              0 Vote for this issue
              9 Start watching this issue