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

C2: MemorySegment double accesses don't vectorize

XMLWordPrintable

      This came up in:
      https://mail.openjdk.org/pipermail/panama-dev/2024-March/020327.html

      "But then why does this one:

          public void scalarSegmentArray(Data state) {
              final MemorySegment input = state.inputSegment;
              final double[] output = state.outputArray;
              for(int i = 0; i < SIZE; i++) {
                  output[i] += input.getAtIndex(JAVA_DOUBLE, i);
              }
          }

      not vectorize? input and output can't overlap because one is off heap
      and the other is on heap. It seems for doubles the MemorySegment API
      reads a double in 2 steps: use getLongUnaligned() and then convert the
      result to double with Double.longBitsToDouble(). The vectorizer doesn't
      support vectorization of that long to double move."

      "MemorySegment reads double in the same way as other (pre-existing)
      VarHandles - e.g. as longs which are then converted to doubles (w/o
      using Unsafe::getDouble directly)."

      "I prefer to see vectorizer handling "MoveX2Y (LoadX mem)"
      => "VectorReinterpret (LoadVector mem)" well and then introduce rules to
      strength-reduce it to mismatched access."

            epeter Emanuel Peter
            roland Roland Westrelin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: