summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/builtins/ppc
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2018-09-24 20:39:19 +0000
committerJordan Rupprecht <rupprecht@google.com>2018-09-24 20:39:19 +0000
commitdc48c4fff4fdb61ebad48b62ae1f21a32af1e50c (patch)
tree78dc33292c84a5586e62f7a0f19830d357ee69b5 /compiler-rt/lib/builtins/ppc
parent0b4ad7596f0141e9c804e8275b7ca4f33baa3efc (diff)
downloadbcm5719-llvm-dc48c4fff4fdb61ebad48b62ae1f21a32af1e50c.tar.gz
bcm5719-llvm-dc48c4fff4fdb61ebad48b62ae1f21a32af1e50c.zip
[compiler-rt] [builtins] Add logb/logbf/logbl methods to compiler-rt to avoid libm dependencies when possible.
Summary: The complex division builtins (div?c3) use logb methods from libm to scale numbers during division and avoid rounding issues. However, these come from libm, meaning anyone that uses --rtlib=compiler-rt also has to include -lm. Implement logb* methods for standard ieee 754 floats so we can avoid -lm on those platforms, falling back to the old behavior (using either logb() or `__builtin_logb()`) when not supported. These new methods are defined internally as `__compiler_rt_logb` so as not to conflict with the libm definitions in any way. This fixes just the libm methods mentioned in PR32279 and PR28652. libc is still required, although that seems to not be an issue. Note: this is proposed as an alternative to just adding -lm: D49330. Reviewers: efriedma, compnerd, scanon, echristo Reviewed By: echristo Subscribers: jsji, echristo, nemanjai, dberris, mgorny, kbarton, delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D49514 llvm-svn: 342917
Diffstat (limited to 'compiler-rt/lib/builtins/ppc')
-rw-r--r--compiler-rt/lib/builtins/ppc/divtc3.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler-rt/lib/builtins/ppc/divtc3.c b/compiler-rt/lib/builtins/ppc/divtc3.c
index 8ec41c528ab..ef532b84114 100644
--- a/compiler-rt/lib/builtins/ppc/divtc3.c
+++ b/compiler-rt/lib/builtins/ppc/divtc3.c
@@ -4,6 +4,11 @@
#include "DD.h"
#include "../int_math.h"
+// Use DOUBLE_PRECISION because the soft-fp method we use is logb (on the upper
+// half of the long doubles), even though this file defines complex division for
+// 128-bit floats.
+#define DOUBLE_PRECISION
+#include "../fp_lib.h"
#if !defined(CRT_INFINITY) && defined(HUGE_VAL)
#define CRT_INFINITY HUGE_VAL
@@ -21,9 +26,10 @@ __divtc3(long double a, long double b, long double c, long double d)
DD dDD = { .ld = d };
int ilogbw = 0;
- const double logbw = crt_logb(crt_fmax(crt_fabs(cDD.s.hi), crt_fabs(dDD.s.hi) ));
-
- if (crt_isfinite(logbw))
+ const double logbw = __compiler_rt_logb(
+ crt_fmax(crt_fabs(cDD.s.hi), crt_fabs(dDD.s.hi)));
+
+ if (crt_isfinite(logbw))
{
ilogbw = (int)logbw;
OpenPOWER on IntegriCloud