[PATCH] libstdc++: simd: map 64-bit long double to double on sse [PR124657]

Matthias Kretz MatthiasKretz@gmx.net
Wed Apr 22 07:01:09 GMT 2026


Alexandre Oliva [Friday, 10 April 2026, 00:11:02 CEST]:
> On Mar 26, 2026, Matthias Kretz <MatthiasKretz@gmx.net> wrote:
> > For whatever reason, this is the first email I received of this thread.
> 
> I guess I could have copied you.

Here's the strange thing: Your mail reached me only via gcc-patches (which I'm 
subscribed to with my m.kretz@gsi.de address). The libstdc++ mails and your CC 
to MatthiasKretz@gmx.net did not reach my inbox. And I can't find it in the 
Junk folder either.

Email hasn't been my friend in recent years. :(

> 
> > I fear that this might lead to problems further down in the
> > implementation. I think this should rather map '__intrinsic_type<long
> > double, N>' to '[[gnu::vector_size(16/32/64)]] double'. PPC has to do a
> > similar thing (below).
> 
> Indeed, I had filed PR124657 about the remaining compile failure with my
> previous change, and your point above was exactly the solution for that
> bit.  But it got me to a subsequent problem that I'm addressing in a
> later patch.
> 
> 
> When long double is as wide as double on x86 (-mlong-double-64), make
> the __intrinsic_type a vector of double.
> 
> Regstrapped on x86_64-linux-gnu.  This is not enough to enable
> experimental/simd/pr109261_constexpr_simd.cc to compile with
> -mlong-double-64.  Ok to install?
> 
> 
> for  libstdc++-v3/ChangeLog
> 
> 	PR libstdc++/124657
> 	* include/experimental/bits/simd.h (__intrinsic_type::type):
> 	Map long double to double.
> ---
>  libstdc++-v3/include/experimental/bits/simd.h |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libstdc++-v3/include/experimental/bits/simd.h
> b/libstdc++-v3/include/experimental/bits/simd.h index
> b96818af6e6ff..8c30c8af26881 100644
> --- a/libstdc++-v3/include/experimental/bits/simd.h
> +++ b/libstdc++-v3/include/experimental/bits/simd.h
> @@ -2477,7 +2477,8 @@ template <typename _Tp, size_t _Bytes>
>      static constexpr size_t _S_VBytes = _Bytes <= 16 ? 16 : _Bytes <= 32 ?
> 32 : 64;
> 
>      using type [[__gnu__::__vector_size__(_S_VBytes)]]
> -      = conditional_t<is_integral_v<_Tp>, long long int, _Tp>;
> +      = conditional_t<is_integral_v<_Tp>, long long int,
> +		      conditional_t<is_same_v<_Tp, long double>, double, 
_Tp> >;
>    };
>  #endif // _GLIBCXX_SIMD_HAVE_SSE

Looks good. But I would also prefer to make it cheaper for the standard 80-bit 
long double case by guarding the extra conditional_t behind a

#if __LDBL_MANT_DIG == __DBL_MANT_DIG


-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Center for Heavy Ion Research               https://gsi.de
 std::simd
──────────────────────────────────────────────────────────────────────────





More information about the Libstdc++ mailing list