Closed farzonl closed 2 weeks ago
Need resolution to #87367 before we can do this.
Note: #87367 was unblocked via https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294. The path forward was decided that dot would be a generic intrinsic. That should make the spirv side of this change trivial
if we did that we would likely want to move getDotProductIntrinsic
to DXILIntrinsicExpansion.cpp and rewrite it as an expansion to replace the generic with the eqivalent dx dot2-4 intrinsic .
static bool expandDot(CallInst *Orig) {
...
Orig->replaceAllUsesWith(MaxCall);
Orig->eraseFromParent();
}
Would also need a way of signallying that an intrinsic is needed for expansion:
static bool isIntrinsicExpansion(Function &F) {
switch (F.getIntrinsicID()) {
case Intrinsic::dot:
...
return true;
}
return false;
}
One complication though would be we would need a generic vector dot operaton that will do element extractions, fmuls, and element insertions.
@llvm/issue-subscribers-clang-codegen
Author: Farzon Lotfi (farzonl)
Add an intrinsic like this one from https://github.com/llvm/llvm-project/blob/1e6ce5e284f5c0e8d64eee21af727bb164eb3caf/llvm/include/llvm/IR/IntrinsicsDirectX.td#L28
to https://github.com/llvm/llvm-project/blob/1e6ce5e284f5c0e8d64eee21af727bb164eb3caf/llvm/include/llvm/IR/IntrinsicsSPIRV.td#L59
We won't need dot2,dot3,dot4 for spirv which adds a bit of a complication on our switching, Come with an intrinsic switching behavior that allows for per backend specializations. maybe as a per backend lambda?
update the dot.hlsl unit tests: https://github.com/llvm/llvm-project/blob/1e6ce5e284f5c0e8d64eee21af727bb164eb3caf/clang/test/CodeGenHLSL/builtins/dot.hlsl#L1
and implement the
OpDot
Lowering: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpDot