[clang] [llvm] [HLSL][DirectX] Implement HLSL `mul` function and DXIL lowering of `llvm.matrix.multiply` (PR #184882)
Deric C. via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 5 15:49:53 PST 2026
================
@@ -58,6 +58,21 @@ 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];
----------------
Icohedron wrote:
I pushed a commit to perform the optimizations I described 04e744f4c17a4d08feaecb3a7b6eb78f32903121 by making the lowering of the vector-vector case be handled by codegen for the mul builtin.
https://github.com/llvm/llvm-project/pull/184882
More information about the cfe-commits
mailing list