Date: Fri, 16 Jan 2026 18:28:48 +0100
On 16/01/2026 17:52, Thiago Macieira wrote:
> On Friday, 16 January 2026 08:40:32 Pacific Standard Time David Brown wrote:
>>> It happens *all* the time with long double. And it depends on *how* the
>>> thing is copied. If it is done by copying memory, the bits will come
>>> through. If it is done by the x87 stack, they will not and the
>>> destination's previous bits will remain unchanged.
>>
>> I did not think x87 floating point was much used any more - my
>> understanding was that floating point was primarily handled with SIMD
>> instructions and registers for greater efficiency. But my knowledge
>> here is minimal (I target small embedded systems), so I accept your
>> experience.
>
> long double on most ABIs is still 80-bit extended precision and therefore uses
> the x87.
> https://gcc.godbolt.org/z/9K7vdWPx9
>
> As you can see from the MSVC pane, Windows is the outlier.
>
> BTW, this does mean the Standard Library <random> routines that use long
> double are extremely slow.
>
So x87 instructions and registers are used for long double in the x86,
but SSE instructions (and xmm registers) are used for double and float,
right?
Do you see much use for long double in real code?
> PS: strictly speaking, it's "SSE instructions" not "SIMD": as the MSVC output
> shows, it's using a scalar instruction, therefore not SIMD.
>
Sorry for the poor terminology - I will try to get it right in the future!
(This is getting quite off-topic for this list, so I will stop asking
after this post - but I appreciate your information and answers here.)
> On Friday, 16 January 2026 08:40:32 Pacific Standard Time David Brown wrote:
>>> It happens *all* the time with long double. And it depends on *how* the
>>> thing is copied. If it is done by copying memory, the bits will come
>>> through. If it is done by the x87 stack, they will not and the
>>> destination's previous bits will remain unchanged.
>>
>> I did not think x87 floating point was much used any more - my
>> understanding was that floating point was primarily handled with SIMD
>> instructions and registers for greater efficiency. But my knowledge
>> here is minimal (I target small embedded systems), so I accept your
>> experience.
>
> long double on most ABIs is still 80-bit extended precision and therefore uses
> the x87.
> https://gcc.godbolt.org/z/9K7vdWPx9
>
> As you can see from the MSVC pane, Windows is the outlier.
>
> BTW, this does mean the Standard Library <random> routines that use long
> double are extremely slow.
>
So x87 instructions and registers are used for long double in the x86,
but SSE instructions (and xmm registers) are used for double and float,
right?
Do you see much use for long double in real code?
> PS: strictly speaking, it's "SSE instructions" not "SIMD": as the MSVC output
> shows, it's using a scalar instruction, therefore not SIMD.
>
Sorry for the poor terminology - I will try to get it right in the future!
(This is getting quite off-topic for this list, so I will stop asking
after this post - but I appreciate your information and answers here.)
Received on 2026-01-16 17:28:54
