[llvm] [DirectX][LongVec] Support large vector splitting for dot product (PR #216383)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 23:07:28 PDT 2026


================
@@ -434,24 +441,48 @@ static Value *expandFloatDotIntrinsic(CallInst *Orig, Value *A, Value *B) {
   default:
     reportFatalUsageError(
         "Invalid dot product input vector: length is outside 2-4");
-    return nullptr;
   }
 
   SmallVector<Value *> Args;
-  for (int I = 0; I < NumElts; ++I)
+  for (unsigned I = 0; I < NumElts; ++I)
     Args.push_back(Builder.CreateExtractElement(A, Builder.getInt32(I)));
-  for (int I = 0; I < NumElts; ++I)
+  for (unsigned I = 0; I < NumElts; ++I)
     Args.push_back(Builder.CreateExtractElement(B, Builder.getInt32(I)));
   return Builder.CreateIntrinsic(ATy->getScalarType(), DotIntrinsic, Args,
                                  nullptr, "dot");
 }
 
-// Create the appropriate DXIL float dot intrinsic for the operands of Orig
-// The appropriate opcode will be determined by the size of the operands
-// The dot product is placed in the position indicated by Orig
+// Expand an arbitrary-width float dot into the minimum number of legal DXIL
+// dot2, dot3, and dot4 operations.
 static Value *expandFloatDotIntrinsic(CallInst *Orig) {
-  return expandFloatDotIntrinsic(Orig, Orig->getOperand(0),
-                                 Orig->getOperand(1));
+  Value *A = Orig->getOperand(0);
+  Value *B = Orig->getOperand(1);
+  unsigned NumElts = cast<FixedVectorType>(A->getType())->getNumElements();
+
+  if (NumElts <= 4)
----------------
farzonl wrote:

```suggestion
  //  We return early here to avoid constructing unnecessary identity shuffles.
  if (NumElts <= 4)
```

https://github.com/llvm/llvm-project/pull/216383


More information about the llvm-commits mailing list