aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/mips
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2017-11-28 20:37:27 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2017-11-28 20:37:27 +0000
commit55c6cacd56018de1a0b9f3004d73a29cf6983521 (patch)
tree914f3be6e98186e51f74a29eab3b066894acc3a1 /lib/libc/mips
parenteb7ec397044cc2b16fe369b8df4d1718838e463c (diff)
downloadsrc-55c6cacd56018de1a0b9f3004d73a29cf6983521.tar.gz
src-55c6cacd56018de1a0b9f3004d73a29cf6983521.zip
Fix fabs() for MIPS when used on -0.0
It would previously return negative zero for -0.0 since -0.0 does not compare less than 0. The issue was discovered when running the libc++ test suite on softfloat MIPS64. I have verified that both clang and GCC generate sensible code for the builtin. For soft float they clear the sign bit using integer operations and in hard float mode they use abs.d. Reviewed by: #mips, jhb, brooks, imp, emaste Approved by: jhb (mentor) Differential Revision: https://reviews.freebsd.org/D13135
Notes
Notes: svn path=/head/; revision=326342
Diffstat (limited to 'lib/libc/mips')
-rw-r--r--lib/libc/mips/gen/fabs.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libc/mips/gen/fabs.c b/lib/libc/mips/gen/fabs.c
index 6730a6746289..9c51f43ff4e7 100644
--- a/lib/libc/mips/gen/fabs.c
+++ b/lib/libc/mips/gen/fabs.c
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
double
fabs(double x)
{
- if (x < 0)
- x = -x;
- return(x);
+
+ return (__builtin_fabs(x));
}