aboutsummaryrefslogtreecommitdiff
path: root/math/powf.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2018-12-07 14:58:51 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2018-12-07 14:58:51 +0000
commit04884bd04eac4b251da4026900010ea7d8850edc (patch)
tree33c966ee96c845a40dc64ecf3bac969e76c69bc1 /math/powf.c
parent75b8d8c6c12b37a38211defcc5b941adb7de121f (diff)
downloadarm-optimized-routines-04884bd04eac4b251da4026900010ea7d8850edc.tar.gz
More consistent excess precision handling
The current code aims to support FLT_EVAL_METHOD!=0 targets (such as i386 with x87 fpu or m68k) assuming appropriate narrowing eval functions are defined for them. But the narrowing eval functions were not used consistently: the return statement may not guarantee narrowing (e.g. that was the C99 behaviour which got changed in C11 annex F) so we should use the narrowing eval_as_ functions at return statements too. Results should be correct if narrowing only happens at eval_as_ calls. On most targets this change has no effect because eval_as_ is a noop. Most math implementations that care about excess precision already compile in a mode that narrows at returns so this change is not necessary for them, just better documents the assumptions.
Diffstat (limited to 'math/powf.c')
-rw-r--r--math/powf.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/math/powf.c b/math/powf.c
index 06116f0..385719b 100644
--- a/math/powf.c
+++ b/math/powf.c
@@ -74,7 +74,7 @@ log2_inline (uint32_t ix)
/* The output of log2 and thus the input of exp2 is either scaled by N
(in case of fast toint intrinsics) or not. The unscaled xd must be
in [-1021,1023], sign_bias sets the sign of the result. */
-static inline double_t
+static inline float
exp2_inline (double_t xd, uint32_t sign_bias)
{
uint64_t ki, ski, t;
@@ -106,7 +106,7 @@ exp2_inline (double_t xd, uint32_t sign_bias)
y = C[2] * r + 1;
y = z * r2 + y;
y = y * s;
- return y;
+ return eval_as_float (y);
}
/* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is
@@ -214,7 +214,7 @@ powf (float x, float y)
return __math_may_uflowf (sign_bias);
#endif
}
- return (float) exp2_inline (ylogx, sign_bias);
+ return exp2_inline (ylogx, sign_bias);
}
#if USE_GLIBC_ABI
strong_alias (powf, __powf_finite)