[clang] [llvm] [HLSL][DirectX] Implement HLSL `mul` function and DXIL lowering of `llvm.matrix.multiply` (PR #184882)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 22:14:00 PST 2026


================
@@ -58,21 +58,6 @@ constexpr float dot2add_impl(half2 a, half2 b, float c) {
 #endif
 }
 
-template <typename T, int N>
-constexpr enable_if_t<!is_same<double, T>::value, T>
-mul_vec_impl(vector<T, N> x, vector<T, N> y) {
-  return dot(x, y);
-}
-
-// Double vectors do not have a dot intrinsic, so expand manually.
-template <typename T, int N>
-enable_if_t<is_same<double, T>::value, T> mul_vec_impl(vector<T, N> x,
-                                                       vector<T, N> y) {
-  T sum = x[0] * y[0];
-  [unroll] for (int i = 1; i < N; ++i) sum += x[i] * y[i];
-  return sum;
----------------
farzonl wrote:

We already implemented `__builtin_hlsl_mad` and that uses Intrinsic::fmuladd. you could have used that here.

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


More information about the cfe-commits mailing list