[clang] [llvm] [HLSL] Move length support out of the DirectX Backend (PR #121611)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 3 15:18:05 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff a106ad0f1d0f74fde3591149c63f3e94ec780fef 74ad2ec542078c61064a103e1ea3154057489ccb --extensions cpp,h -- clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGHLSLRuntime.h clang/lib/Headers/hlsl/hlsl_detail.h clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/lib/Sema/SemaHLSL.cpp llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Headers/hlsl/hlsl_detail.h b/clang/lib/Headers/hlsl/hlsl_detail.h
index ac4710e9f8..392075d276 100644
--- a/clang/lib/Headers/hlsl/hlsl_detail.h
+++ b/clang/lib/Headers/hlsl/hlsl_detail.h
@@ -52,9 +52,7 @@ 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];
+ [unroll] for (int i = 1; i < N; ++i) XSquaredSum += XSquared[i];
return __builtin_elementwise_sqrt(XSquaredSum);
}
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index f51cd28bb4..cf287e598f 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -1300,13 +1300,11 @@ float4 lerp(float4, float4, float4);
const inline half length(half X) { return __detail::length_impl(X); }
const inline float length(float X) { return __detail::length_impl(X); }
-template <int N>
-const inline half length(vector<half, N> X) {
+template <int N> const inline half length(vector<half, N> X) {
return __detail::length_vec_impl(X);
}
-template <int N>
-const inline float length(vector<float, N> X) {
+template <int N> const inline float length(vector<float, N> X) {
return __detail::length_vec_impl(X);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/121611
More information about the llvm-commits
mailing list