aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Kretz <m.kretz@gsi.de>2023-05-24 16:43:07 +0200
committerMatthias Kretz <m.kretz@gsi.de>2023-05-24 21:34:16 +0200
commitefd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9 (patch)
treee9b4dacdab63090b69cbc6a3c3bdf4bf14ea6049
parent003e641f0cd97d9f014dea756cb832143ab8d5ed (diff)
downloadgcc-efd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9.zip
gcc-efd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9.tar.gz
gcc-efd2b55d8562c6e80cb7ee8b9b1f9418f0c00cd9.tar.bz2
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.
-rw-r--r--libstdc++-v3/include/experimental/bits/simd.h39
-rw-r--r--libstdc++-v3/include/experimental/bits/simd_ppc.h3
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 d1f3883..26f08f8 100644
--- a/libstdc++-v3/include/experimental/bits/simd.h
+++ b/libstdc++-v3/include/experimental/bits/simd.h
@@ -2466,11 +2466,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 eca1b34..2ea7234 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, typename>
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))
{