[PATCH] libstdc++: Correct NTTP and simd_mask ctor call
Matthias Kretz
m.kretz@gsi.de
Fri Jun 2 08:50:33 GMT 2023
Hello Alexandre,
On Friday, 2 June 2023 10:32:40 CEST Alexandre Oliva wrote:
> On May 26, 2023, Matthias Kretz via Libstdc++ <libstdc++@gcc.gnu.org> wrote:
> > OK for master and all backports (after 11.4 is done)?
> > tested on powerpc64le-linux-gnu and x86_64-pc-linux-gnu
> >
> > * testsuite/experimental/simd/pr109822_cast_functions.cc: New
> > test.
>
> This testcase fails to compile on PowerPC targets without VSX: 64-bit
> integer and floating-point types cannot be vectorized.
Yes, and the simd implementation already encodes that both in
__vectorized_sizeof<T>() and __intrinsic_type<T>.
> I wonder if the test is malformed (and should be amended to test for
> available simd types), or whether a patch like this would be desirable
> to make simd constructs more portable. I'm not sure about the
> requirements.
The test is correct. The stdx::simd implementation has a latent bug (my
dejagnu boards included only POWER7-POWER9; I'm at POWER5-POWER10 by now). The
_S_store function is trying to work around bad code-gen but fails to notice
that long long vectors can't be used.
I'm looking at that function again, also in light of recent improvements wrt.
code-gen, and will remove that assumption, that long long is vectorizable.
__intrinsic_type_t<T> should never be T, but always the type that can be
passed to corresponding platform intrinsics. There are traits for the
implementation to detect whether the intrinsics types are available.
- Matthias
>
>
> [libstdc++] [simd] [ppc] use nonvector intrinsic fallback types
>
> From: Alexandre Oliva <oliva@adacore.com>
>
> Compiling such tests as pr109822_cast_functions.cc on powerpc targets
> that don't support VSX fails because some intrinsic types that are
> expected to be vectorizable are not defined without VSX.
>
> Introduce fallback non-vector types to enable the code to compile.
>
>
> for libstdc++-v3/ChangeLog
>
> * include/experimental/bits/simd.h: Introduce fallback
> non-vector intrinsic_type_impl specializations for PowerPC
> without VSX.
> ---
> libstdc++-v3/include/experimental/bits/simd.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/libstdc++-v3/include/experimental/bits/simd.h
> b/libstdc++-v3/include/experimental/bits/simd.h index
> 834fe923065bd..2691823e869e8 100644
> --- a/libstdc++-v3/include/experimental/bits/simd.h
> +++ b/libstdc++-v3/include/experimental/bits/simd.h
> @@ -2431,9 +2431,14 @@ template <typename _Tp>
> #define _GLIBCXX_SIMD_PPC_INTRIN(_Tp)
> \ template <>
> \ struct __intrinsic_type_impl<_Tp> { using type = __vector _Tp; }
> +#define _GLIBCXX_SIMD_PPC_INTRIN_NOVEC(_Tp)
\
> + template <>
> \ + struct __intrinsic_type_impl<_Tp> { using type = _Tp; }
> _GLIBCXX_SIMD_PPC_INTRIN(float);
> #ifdef __VSX__
> _GLIBCXX_SIMD_PPC_INTRIN(double);
> +#else
> +_GLIBCXX_SIMD_PPC_INTRIN_NOVEC(double);
> #endif
> _GLIBCXX_SIMD_PPC_INTRIN(signed char);
> _GLIBCXX_SIMD_PPC_INTRIN(unsigned char);
> @@ -2444,12 +2449,19 @@ _GLIBCXX_SIMD_PPC_INTRIN(unsigned int);
> #if defined __VSX__ || __SIZEOF_LONG__ == 4
> _GLIBCXX_SIMD_PPC_INTRIN(signed long);
> _GLIBCXX_SIMD_PPC_INTRIN(unsigned long);
> +#else
> +_GLIBCXX_SIMD_PPC_INTRIN_NOVEC(signed long);
> +_GLIBCXX_SIMD_PPC_INTRIN_NOVEC(unsigned long);
> #endif
> #ifdef __VSX__
> _GLIBCXX_SIMD_PPC_INTRIN(signed long long);
> _GLIBCXX_SIMD_PPC_INTRIN(unsigned long long);
> +#else
> +_GLIBCXX_SIMD_PPC_INTRIN_NOVEC(signed long long);
> +_GLIBCXX_SIMD_PPC_INTRIN_NOVEC(unsigned long long);
> #endif
> #undef _GLIBCXX_SIMD_PPC_INTRIN
> +#undef _GLIBCXX_SIMD_PPC_INTRIN_NOVEC
>
> template <typename _Tp, size_t _Bytes>
> struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp>
> && _Bytes <= 16>>
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
stdₓ::simd
──────────────────────────────────────────────────────────────────────────
More information about the Libstdc++
mailing list