1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 00:52:12 +00:00

LibM: Use assembly for all atan versions

This commit is contained in:
Hendiadyoin1 2021-07-05 16:56:06 +02:00 committed by Andreas Kling
parent 119f280f34
commit b583726deb

View file

@ -729,50 +729,61 @@ float coshf(float x) NOEXCEPT
long double atan2l(long double y, long double x) NOEXCEPT
{
if (x == 0) {
if (y > 0)
return M_PI_2;
if (y < 0)
return -M_PI_2;
return 0;
}
long double result = 0; //atanl(y / x);
__asm__("fpatan"
: "=t"(result)
: "0"(x), "u"(y)
: "st(1)");
asm("fpatan"
: "=t"(result)
: "0"(x), "u"(y)
: "st(1)");
return result;
}
double atan2(double y, double x) NOEXCEPT
{
return (double)atan2l(y, x);
double result = 0; //atanl(y / x);
asm("fpatan"
: "=t"(result)
: "0"(x), "u"(y)
: "st(1)");
return result;
}
float atan2f(float y, float x) NOEXCEPT
{
return (float)atan2l(y, x);
float result = 0; //atanl(y / x);
asm("fpatan"
: "=t"(result)
: "0"(x), "u"(y)
: "st(1)");
return result;
}
long double atanl(long double x) NOEXCEPT
{
if (x < 0)
return -atanl(-x);
if (x > 1)
return M_PI_2 - atanl(1 / x);
long double squared = x * x;
return x / (1 + 1 * 1 * squared / (3 + 2 * 2 * squared / (5 + 3 * 3 * squared / (7 + 4 * 4 * squared / (9 + 5 * 5 * squared / (11 + 6 * 6 * squared / (13 + 7 * 7 * squared)))))));
asm(
"fld1\n"
"fpatan\n"
: "=t"(x)
: "0"(x));
return x;
}
double atan(double x) NOEXCEPT
{
return (double)atanl(x);
asm(
"fld1\n"
"fpatan\n"
: "=t"(x)
: "0"(x));
return x;
}
float atanf(float x) NOEXCEPT
{
return (float)atanl(x);
asm(
"fld1\n"
"fpatan\n"
: "=t"(x)
: "0"(x));
return x;
}
long double asinl(long double x) NOEXCEPT