Remove obsolete hacks for the fabs() family.

We don't support GCC any more, and clang's got better since this commit
was written. It doesn't produce _identical_ code, but it's a similar
single-instruction bit twiddle.

This also doesn't regress x86 for fabsl (that code looks the same before
and after) and there is no riscv32.

Test: llvm-objdump -d
Change-Id: I7acea6fd26f8760763f3744201ed42a99186562b
This commit is contained in:
Elliott Hughes 2022-12-05 20:58:15 +00:00
parent 8262ca1dd8
commit 591a2a798d
1 changed files with 2 additions and 25 deletions

View File

@ -18,32 +18,9 @@
#include "fpmath.h"
double fabs(double x) {
#if __arm__
// Both Clang and GCC insist on moving r0/r1 into a double register
// and using fabs where bit-twiddling would be a better choice.
// They get fabsf right, but we need to be careful in fabsl too.
IEEEd2bits u;
u.d = x;
u.bits.sign = 0;
return u.d;
#else
return __builtin_fabs(x);
#endif
}
float fabsf(float x) {
return __builtin_fabsf(x);
}
#if defined(__LP64__)
double fabs(double x) { return __builtin_fabs(x); }
float fabsf(float x) { return __builtin_fabsf(x); }
long double fabsl(long double x) { return __builtin_fabsl(x); }
#else
long double fabsl(long double x) {
// Don't use __builtin_fabs here because of ARM. (See fabs above.)
return fabs(x);
}
#endif
#if defined(__aarch64__)
float ceilf(float x) { return __builtin_ceilf(x); }