[PATCH v2] libstdc++: simd: x86: accept 64-bit long double as double [PR124657]
Matthias Kretz
MatthiasKretz@gmx.net
Wed Apr 22 07:07:16 GMT 2026
OK from my side.
> Jonathan, should I credit you for the preprocessor micro-optimization?
> I didn't quite follow it to the letter, because I thought it looked
> cleaner this way, and IIUC it would not bring any notable inefficiency.
see below
Alexandre Oliva [Wednesday, 22 April 2026, 08:20:28 CEST]:
> diff --git a/libstdc++-v3/include/experimental/bits/simd_x86.h
> b/libstdc++-v3/include/experimental/bits/simd_x86.h index
> 74c7a61998e0d..5d4ed5ad58c8e 100644
> --- a/libstdc++-v3/include/experimental/bits/simd_x86.h
> +++ b/libstdc++-v3/include/experimental/bits/simd_x86.h
> @@ -415,13 +415,31 @@ template <size_t _Np, typename _Tp, typename _Kp>
> #endif
>
> // ISA & type detection {{{
> +template <typename _Tp>
> + constexpr bool
> + __is_x86_ps()
> + {
> + return is_same_v<_Tp, float>;
> + }
> +
> +template <typename _Tp>
> + constexpr bool
> + __is_x86_pd()
> + {
> +#if __LDBL_MANT_DIG == __DBL_MANT_DIG
> + if constexpr (is_same_v<_Tp, long double>)
> + return true;
> +#endif
> + return is_same_v<_Tp, double>;
> + }
I believe Jonathan's approach would not instantiate is_same_v<_Tp, long
double> for __is_x86_pd<double>(). Yours always instantiates both is_same_v
templates for any _Tp.
However, this is certainly fine for the usual case (where long double is not
64 bits). And by now I doubt there's any measurable difference with -mlong-
double-64 even between this and what Jonathan suggested. (because there are
very few instantiations of __is_x86_pd anyway and is_same_v will surely get
instantiated somewhere already.)
- Matthias
--
──────────────────────────────────────────────────────────────────────────
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