[PATCH v2] libstdc++: simd: x86: accept 64-bit long double as double [PR124657]

Alexandre Oliva oliva@adacore.com
Tue Apr 28 21:48:37 GMT 2026


On Apr 22, 2026, Matthias Kretz <MatthiasKretz@gmx.net> wrote:

>> 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.

>> +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.

That's true.  But as noted in the other follow-up patch, is_same_v<_Tp,
long double> is necessarily instantiated in struct __intrinsic_type, so
as you say, it will surely be instantiated somewhere already.  By moving
the necessarily-instantiated case first, we may conceivably avoid the
instantiation of the other in the one case it is avoidable.

So yeah, I didn't follow the suggestion to the letter, but I followed
its spirit ;-)

-- 
Alexandre Oliva, happy hacker            https://blog.lx.oliva.nom.br/
Free Software Activist     FSFLA co-founder     GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!


More information about the Libstdc++ mailing list