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

[SuperWord] Allow MulReductionVL not just for avx512dq

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      Currently MulReductionVL is only allowed with avx512dq support.

          case Op_MulReductionVL:
            if (VM_Version::supports_avx512dq() == false) {
              return false;
            }

      https://github.com/openjdk/jdk/blob/3dfadeebd023efb03a400f2b2656567a4154421a/src/hotspot/cpu/x86/x86.ad#L1437-L1440

      The relevant vpmullq instruction exists also on earlier AVX versions. (Ah no, it actually only exists for AVX512, my bad.)
      https://www.felixcloutier.com/x86/pmulld:pmullq

      See attached Test.java for an example.

      Does not vectorize:
      ./java -XX:-TieredCompilation -Xbatch -XX:CompileCommand=compileonly,Test::test -XX:+TraceSuperWord -XX:UseAVX=2 Test.java

      Vectorizes, provided your machine has avx512dq support.
      ./java -XX:-TieredCompilation -Xbatch -XX:CompileCommand=compileonly,Test::test -XX:+TraceSuperWord -XX:UseAVX=3 Test.java

      Code snippet:
          static long test(long[] data) {
              long mul = 1;
              for (int i = 2; i < N-2; i++) {
                  long v = data[i] + 5;
                  mul *= v; // MulReductionVL currently requires avx512dq support
              }
              return mul;
          }

      I discovered this during the work of JDK-8302139.

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

              Created:
              Updated:
              Resolved: