From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7857) id E11C43857710; Thu, 25 May 2023 07:04:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E11C43857710 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684998242; bh=qtzpLsFUpVhlUN5DWSPK4KVolMOpjEdpFGHK3e+zpmY=; h=From:To:Subject:Date:From; b=QUGceOVD5hIpLrNP6EJ5GAAoAtiRT89PT3a8gIeIuTThU99ugx0MxMVOeK+VeLLwJ JjBVhxrXuOJJKFycvZjQYWs0yfoXwXT5bTGPKD93takeUYOw+rQNQ7xTlwQTERH+xf +cezxkms0PA+QIwrg3wz3ytdGBT3X0WnxJgiXfzk= 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 r13-7374] libstdc++: Fix type of first argument to vec_cntm call X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: a51ed14784df49eeceea1813b1d458516031bf52 X-Git-Newrev: 0ed75609477ce9e83f8ebc32a7fa0f86380ad22f Message-Id: <20230525070402.E11C43857710@sourceware.org> Date: Thu, 25 May 2023 07:04:02 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0ed75609477ce9e83f8ebc32a7fa0f86380ad22f commit r13-7374-g0ed75609477ce9e83f8ebc32a7fa0f86380ad22f Author: Matthias Kretz Date: Wed May 24 16:43:07 2023 +0200 libstdc++: Fix type of first argument to vec_cntm call Signed-off-by: Matthias Kretz 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 b7c756436e1..692046d23a4 100644 --- a/libstdc++-v3/include/experimental/bits/simd.h +++ b/libstdc++-v3/include/experimental/bits/simd.h @@ -2466,11 +2466,40 @@ template "no __intrinsic_type support for 64-bit floating point on PowerPC w/o VSX"); #endif - using type = - typename __intrinsic_type_impl< - conditional_t, - 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::type; }; #endif // __ALTIVEC__ diff --git a/libstdc++-v3/include/experimental/bits/simd_ppc.h b/libstdc++-v3/include/experimental/bits/simd_ppc.h index eca1b34241b..2ea7234bd99 100644 --- a/libstdc++-v3/include/experimental/bits/simd_ppc.h +++ b/libstdc++-v3/include/experimental/bits/simd_ppc.h @@ -130,7 +130,8 @@ template const auto __kv = __as_vector(__k); if constexpr (__have_power10vec) { - return vec_cntm(__to_intrin(__kv), 1); + using _Intrin = __intrinsic_type16_t>>; + return vec_cntm(reinterpret_cast<_Intrin>(__kv), 1); } else if constexpr (sizeof(_Tp) >= sizeof(int)) {