================ @@ -33,6 +41,21 @@ constexpr enable_if_t<sizeof(U) == sizeof(T), U> bit_cast(T F) { return __builtin_bit_cast(U, F); } +template <typename T> +constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T> +length_impl(T X) { + return __builtin_elementwise_abs(X); +} + +template <typename T, int N> +enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T> +length_vec_impl(vector<T, N> X) { + vector<T, N> XSquared = X * X; + T XSquaredSum = XSquared[0]; + [unroll] for (int i = 1; i < N; ++i) XSquaredSum += XSquared[i]; ---------------- farzonl wrote:
an earlier version essentially did `sqrt(dot(x,x));` I was told not to do that because the implementation in DXC should be considered the spec compliant implementation. https://github.com/llvm/llvm-project/pull/121611 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits