From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7857) id 1D1823854E7C; Tue, 30 May 2023 20:06:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D1823854E7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685477193; bh=GMpkpOlV2KDltT8lEoVgWtCiTK82ASmI6EwSFbeqZHk=; h=From:To:Subject:Date:From; b=CFzTV0zsKN0+pEvY4fYL+X54G+9caLYTtOK8173Z6zULF5orIy6QYh8lFF45BUiGF v17rikoCmgex5M1IPTHN5ykmikLsEb7bG7TldYZHZ+KQ15KDuegQ6ywfK4hAS5GIGQ gZ3Z8utQQ3cL+8k3dsLyPMt9aGPMePuhlTfpnjaE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Matthias Kretz To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-10835] libstdc++: Correct NTTP and simd_mask ctor call X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: c4dc05d1f617c5763be10cf53cc2fac22fa1dcd2 X-Git-Newrev: 39a60f2d5f7bf6806a4c4d7d1f52f139e157e01a Message-Id: <20230530200633.1D1823854E7C@sourceware.org> Date: Tue, 30 May 2023 20:06:33 +0000 (GMT) List-Id: https://gcc.gnu.org/g:39a60f2d5f7bf6806a4c4d7d1f52f139e157e01a commit r11-10835-g39a60f2d5f7bf6806a4c4d7d1f52f139e157e01a Author: Matthias Kretz Date: Fri May 26 12:23:44 2023 +0200 libstdc++: Correct NTTP and simd_mask ctor call Signed-off-by: Matthias Kretz libstdc++-v3/ChangeLog: PR libstdc++/109822 * include/experimental/bits/simd.h (to_native): Use int NTTP as specified in PTS2. (to_compatible): Likewise. Add missing tag to call mask generator ctor. * testsuite/experimental/simd/pr109822_cast_functions.cc: New test. (cherry picked from commit 668d43502f465d48adbc1fe2956b979f36657e5f) Diff: --- libstdc++-v3/include/experimental/bits/simd.h | 7 +-- .../experimental/simd/pr109822_cast_functions.cc | 63 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index cc0f1cc509e..d5683bfcacb 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -3123,7 +3123,7 @@ template return {__mem, vector_aligned}; } -template +template _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == native_simd_mask<_Tp>::size()), native_simd_mask<_Tp>> to_native(const fixed_size_simd_mask<_Tp, _Np>& __x) @@ -3134,7 +3134,7 @@ template } // to_compatible {{{2 -template +template _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == simd<_Tp>::size()), simd<_Tp>> to_compatible(const simd<_Tp, simd_abi::fixed_size<_Np>>& __x) { @@ -3143,12 +3143,13 @@ template return {__mem, vector_aligned}; } -template +template _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == simd_mask<_Tp>::size()), simd_mask<_Tp>> to_compatible(const simd_mask<_Tp, simd_abi::fixed_size<_Np>>& __x) { return simd_mask<_Tp>( + __private_init, [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); } diff --git a/libstdc++-v3/testsuite/experimental/simd/pr109822_cast_functions.cc b/libstdc++-v3/testsuite/experimental/simd/pr109822_cast_functions.cc new file mode 100644 index 00000000000..3deafbf7a1f --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/simd/pr109822_cast_functions.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include + +namespace stdx = std::experimental; + +template + void + test01() + { + using M = typename V::mask_type; + [[maybe_unused]] auto x = to_fixed_size(V()); + [[maybe_unused]] auto k = to_fixed_size(M()); + if constexpr (stdx::simd::size() == V::size()) + { + [[maybe_unused]] auto xx = to_compatible(x); + [[maybe_unused]] auto kk = to_compatible(k); + x = to_fixed_size(xx); + k = to_fixed_size(kk); + } + if constexpr (stdx::native_simd::size() == V::size()) + { + [[maybe_unused]] auto xx = to_native(x); + [[maybe_unused]] auto kk = to_native(k); + x = to_fixed_size(xx); + k = to_fixed_size(kk); + } + } + +template + void + iterate_abis() + { + test01>(); + test01>(); + test01>(); + test01>(); + test01 - 4>>(); + } + +int +main() +{ + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); + iterate_abis(); +}