public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthias Kretz <mkretz@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-10823] libstdc++: Fix type of first argument to vec_cntm call Date: Thu, 25 May 2023 07:05:23 +0000 (GMT) [thread overview] Message-ID: <20230525070523.46C253883018@sourceware.org> (raw) https://gcc.gnu.org/g:0860e7d46f7fa4e1bcd373feee3bc673d4260b8b commit r11-10823-g0860e7d46f7fa4e1bcd373feee3bc673d4260b8b Author: Matthias Kretz <m.kretz@gsi.de> Date: Wed May 24 16:43:07 2023 +0200 libstdc++: Fix type of first argument to vec_cntm call Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: PR libstdc++/109949 * include/experimental/bits/simd.h (__intrinsic_type): If __ALTIVEC__ is defined, map gnu::vector_size types to their corresponding __vector T types without losing unsignedness of integer types. Also prefer long long over long. * include/experimental/bits/simd_ppc.h (_S_popcount): Cast mask object to the expected unsigned vector type. (cherry picked from commit efd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9) Diff: --- libstdc++-v3/include/experimental/bits/simd.h | 39 ++++++++++++++++++++--- libstdc++-v3/include/experimental/bits/simd_ppc.h | 3 +- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/include/experimental/bits/simd.h b/libstdc++-v3/include/experimental/bits/simd.h index 7e877e85f80..a7e9443828e 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -2337,11 +2337,40 @@ template <typename _Tp, size_t _Bytes> "no __intrinsic_type support for 64-bit floating point on PowerPC w/o VSX"); #endif - using type = - typename __intrinsic_type_impl< - conditional_t<is_floating_point_v<_Tp>, - conditional_t<_S_is_ldouble, double, _Tp>, - __int_for_sizeof_t<_Tp>>>::type; + static constexpr auto __element_type() + { + if constexpr (is_floating_point_v<_Tp>) + { + if constexpr (_S_is_ldouble) + return double {}; + else + return _Tp {}; + } + else if constexpr (is_signed_v<_Tp>) + { + if constexpr (sizeof(_Tp) == sizeof(_SChar)) + return _SChar {}; + else if constexpr (sizeof(_Tp) == sizeof(short)) + return short {}; + else if constexpr (sizeof(_Tp) == sizeof(int)) + return int {}; + else if constexpr (sizeof(_Tp) == sizeof(_LLong)) + return _LLong {}; + } + else + { + if constexpr (sizeof(_Tp) == sizeof(_UChar)) + return _UChar {}; + else if constexpr (sizeof(_Tp) == sizeof(_UShort)) + return _UShort {}; + else if constexpr (sizeof(_Tp) == sizeof(_UInt)) + return _UInt {}; + else if constexpr (sizeof(_Tp) == sizeof(_ULLong)) + return _ULLong {}; + } + } + + using type = typename __intrinsic_type_impl<decltype(__element_type())>::type; }; #endif // __ALTIVEC__ diff --git a/libstdc++-v3/include/experimental/bits/simd_ppc.h b/libstdc++-v3/include/experimental/bits/simd_ppc.h index de1e3e76f2a..f1fec53cc79 100644 --- a/libstdc++-v3/include/experimental/bits/simd_ppc.h +++ b/libstdc++-v3/include/experimental/bits/simd_ppc.h @@ -130,7 +130,8 @@ template <typename _Abi> const auto __kv = __as_vector(__k); if constexpr (__have_power10vec) { - return vec_cntm(__to_intrin(__kv), 1); + using _Intrin = __intrinsic_type16_t<make_unsigned_t<__int_for_sizeof_t<_Tp>>>; + return vec_cntm(reinterpret_cast<_Intrin>(__kv), 1); } else if constexpr (sizeof(_Tp) >= sizeof(int)) {
reply other threads:[~2023-05-25 7:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230525070523.46C253883018@sourceware.org \ --to=mkretz@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).