>From 34341757cbaffc878f10676aeb6820f3a02ac29d Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 27 Apr 2019 19:32:49 +0000 Subject: [PATCH 3/3] math: use fp_force_eval and fp_barrier in fma Idiomatic fenv handling with the new fp_arch.h, less portable, but it means a bit smaller code size. --- src/math/fma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/math/fma.c b/src/math/fma.c index 0c6f90c9..84dfeec1 100644 --- a/src/math/fma.c +++ b/src/math/fma.c @@ -1,6 +1,7 @@ #include #include #include +#include "libm.h" #include "atomic.h" #define ASUINT64(x) ((union {double f; uint64_t i;}){x}).i @@ -163,11 +164,10 @@ double fma(double x, double y, double z) r = i; r = 2*r - c; /* remove top bit */ - /* raise underflow portably, such that it - cannot be optimized away */ + /* raise underflow */ { - double_t tiny = DBL_MIN/FLT_MIN * r; - r += (double)(tiny*tiny) * (r-r); + double_t tiny = fp_barrier(DBL_MIN/FLT_MIN); + fp_force_eval(tiny*tiny); } } } else { -- 2.21.0