aboutsummaryrefslogtreecommitdiff
path: root/src/math/x86_64/fabsf.c
blob: 4b84c6e52461b4f7dbb10a4aac292df2a0c6d678 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <math.h>

float fabsf(float x)
{
	float t;
	__asm__ ("pcmpeqd %0, %0" : "=x"(t));          // t = ~0
	__asm__ ("psrld   $1, %0" : "+x"(t));          // t >>= 1
	__asm__ ("andps   %1, %0" : "+x"(x) : "x"(t)); // x &= t
	return x;
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif