Speed up fmaf() on x86

This commit is contained in:
Justine Tunney 2024-03-22 19:26:56 -07:00
parent 640668931d
commit 40b7da8422
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -100,6 +100,16 @@ float fmaf(float x, float y, float z)
#else
#ifdef __x86_64__
if (X86_HAVE(FMA)) {
asm("vfmadd132ss\t%1,%2,%0" : "+x"(x) : "x"(y), "x"(z));
return x;
} else if (X86_HAVE(FMA4)) {
asm("vfmaddss\t%3,%2,%1,%0" : "=x"(x) : "x"(x), "x"(y), "x"(z));
return x;
}
#endif
/* A double has more than twice as much precision than a float,
so direct double-precision arithmetic suffices, except where
double rounding occurs. */