[llvm] [DirectX][LongVec] Support large vector splitting for dot product (PR #216383)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 08:56:41 PDT 2026
================
@@ -433,24 +438,47 @@ 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)
+ return expandFloatDotChunk(Orig, A, B);
----------------
farzonl wrote:
<img width="1788" height="788" alt="Image" src="https://github.com/user-attachments/assets/09c77c1a-22a8-4532-a25c-0e9d35f61824" />
<img width="1622" height="910" alt="Image" src="https://github.com/user-attachments/assets/79bb7b86-5630-433e-b97b-4b7cd4775ce1" />
https://github.com/llvm/llvm-project/pull/216383
More information about the llvm-commits
mailing list