[clang] [llvm] [HLSL][DirectX][SPIRV] Implement the `fma` API (PR #185304)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 08:53:44 PDT 2026


================
@@ -1028,6 +979,22 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
         retType, CGM.getHLSLRuntime().getIsNaNIntrinsic(),
         ArrayRef<Value *>{Op0}, nullptr, "hlsl.isnan");
   }
+  case Builtin::BI__builtin_hlsl_elementwise_fma: {
+    Value *M = EmitScalarExpr(E->getArg(0));
+    Value *A = EmitScalarExpr(E->getArg(1));
+    Value *B = EmitScalarExpr(E->getArg(2));
+    if (CGM.getTarget().getTriple().isDXIL())
+      return Builder.CreateIntrinsic(M->getType(), Intrinsic::dx_fma,
+                                     ArrayRef<Value *>{M, A, B}, nullptr,
+                                     "dx.fma");
+
+    if (CGM.getTarget().getTriple().isSPIRV())
+      return Builder.CreateIntrinsic(M->getType(), Intrinsic::spv_fma,
+                                     ArrayRef<Value *>{M, A, B}, nullptr,
+                                     "spv.fma");
+
+    break;
+  }
----------------
farzonl wrote:

You are hitting this because we just started the matrix HLSL intrinsics work. The plan is to expand all sema restrictions support matrix types.

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


More information about the cfe-commits mailing list