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:
parent
119f280f34
commit
b583726deb
1 changed files with 34 additions and 23 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue