In x86-64, FP arithmetic is done using SSE, so long double is 64 bits.
What usually happens with x86-64 (where SSE instructions are guaranteed), but the program can still use x87, which the compiler can use when using long double .
You can have confirmation of this by compiling such a program using g++ on Linux:
#include <iostream> #include <cstdlib> #include <ctime> int main() { std::srand(std::time(NULL)); float f1=rand(), f2=rand(); double d1=rand(), d2=rand(); long double l1=rand(), l2=rand(); std::cout<<f1*f2<<" "<<d1*d2<<" "<<l1*l2<<std::endl; return 0; }
In the build output, I find mulsd xmm1, xmm0 for product double and mulss xmm0, xmm2 for product float (both SSE instructions), but fmulp st(1), st (instruction x87) for product long double .
So, this confirms that the compiler uses SSE whenever it can, but still allows 80-bit precision calculations through the old x87 instruction set.
Please note: this is a compiler - some compilers (for example, VC ++) always ignore 80-bit precision types and simply treat long double as a synonym for double .
On the other hand, since the x86-64 System V ABI (adopted by Linux) requires a long double 80 bits, the only way for the compiler to perform calculations using all available type precision is to use the x87 instructions.
source share