[clang] [llvm] [HLSL] Move `normalize` implementation to header files (PR #216228)

Kaitlin Peng via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 18:58:41 PDT 2026


================
@@ -28,6 +28,14 @@ length_impl(vector<T, N> X) {
 #endif
 }
 
+template <typename T> constexpr T normalize_impl(T X) {
+#if (__has_builtin(__builtin_spirv_normalize))
+  return __builtin_spirv_normalize(X);
+#else
+  return X * rsqrt(dot(X, X));
----------------
kmpeng wrote:

This can be implemented a few different ways (e.g. `X / length_impl(X)`) but I did it this way to match DXC.

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


More information about the llvm-commits mailing list