[clang] [llvm] [HLSL] Implementation of dot intrinsic (PR #81190)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 23 16:13:54 PST 2024
================
@@ -17959,6 +17964,54 @@ llvm::Value *CodeGenFunction::EmitScalarOrConstFoldImmArg(unsigned ICEArguments,
return Arg;
}
+Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
+ const CallExpr *E) {
+ if (!getLangOpts().HLSL)
+ return nullptr;
+
+ switch (BuiltinID) {
+ case Builtin::BI__builtin_hlsl_dot: {
+ Value *Op0 = EmitScalarExpr(E->getArg(0));
+ Value *Op1 = EmitScalarExpr(E->getArg(1));
+ llvm::Type *T0 = Op0->getType();
+ llvm::Type *T1 = Op1->getType();
+ if (!T0->isVectorTy() && !T1->isVectorTy()) {
+ if (T0->isFloatingPointTy()) {
+ return Builder.CreateFMul(Op0, Op1, "dx.dot");
+ }
+
+ if (T0->isIntegerTy()) {
+ return Builder.CreateMul(Op0, Op1, "dx.dot");
+ }
----------------
llvm-beanz wrote:
nit:
```suggestion
if (T0->isIntegerTy())
return Builder.CreateMul(Op0, Op1, "dx.dot");
```
https://github.com/llvm/llvm-project/pull/81190
More information about the llvm-commits
mailing list