================
@@ -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));
----------------
farzonl wrote:

you should do `X / length(X)`. Look at length implemented above it is just 
`sqrt(dot(X, X));` so that means X/sqrt(dot(X, X)); you are doing X * 
rsqrt(dot(X, X)) --> X * 1/sqrt(dot(X,X) which means you are doing an extra 
multiply which probably gets optomied away by O1 but still would be good not to 
do.

https://github.com/llvm/llvm-project/pull/216228
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to