mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 01:07:34 +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
|
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);
|
long double result = 0; //atanl(y / x);
|
||||||
__asm__("fpatan"
|
asm("fpatan"
|
||||||
: "=t"(result)
|
: "=t"(result)
|
||||||
: "0"(x), "u"(y)
|
: "0"(x), "u"(y)
|
||||||
: "st(1)");
|
: "st(1)");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
double atan2(double y, double x) NOEXCEPT
|
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
|
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
|
long double atanl(long double x) NOEXCEPT
|
||||||
{
|
{
|
||||||
if (x < 0)
|
asm(
|
||||||
return -atanl(-x);
|
"fld1\n"
|
||||||
if (x > 1)
|
"fpatan\n"
|
||||||
return M_PI_2 - atanl(1 / x);
|
: "=t"(x)
|
||||||
long double squared = x * x;
|
: "0"(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)))))));
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
double atan(double x) NOEXCEPT
|
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
|
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
|
long double asinl(long double x) NOEXCEPT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue