提交 41b290ba 编写于 作者: A Alexander Monakov 提交者: Rich Felker

math: move trivial x86-family sqrt functions to C with inline asm

上级 c24a9923
#include <math.h>
long double sqrtl(long double x)
{
__asm__ ("fsqrt" : "+t"(x));
return x;
}
.global sqrtl
.type sqrtl,@function
sqrtl: fldt 4(%esp)
fsqrt
ret
#include <math.h>
double sqrt(double x)
{
__asm__ ("sqrtsd %1, %0" : "=x"(x) : "x"(x));
return x;
}
.global sqrt
.type sqrt,@function
sqrt: sqrtsd %xmm0, %xmm0
ret
#include <math.h>
float sqrtf(float x)
{
__asm__ ("sqrtss %1, %0" : "=x"(x) : "x"(x));
return x;
}
.global sqrtf
.type sqrtf,@function
sqrtf: sqrtss %xmm0, %xmm0
ret
#include <math.h>
long double sqrtl(long double x)
{
__asm__ ("fsqrt" : "+t"(x));
return x;
}
.global sqrtl
.type sqrtl,@function
sqrtl: fldt 8(%rsp)
fsqrt
ret
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册