[PATCH 1/8] math: Sync powf with Arm Optimized Routines
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Feb 26 20:01:47 GMT 2026
Sync with commit 2175be4. No functional change.
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
---
sysdeps/ieee754/flt-32/e_powf.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/sysdeps/ieee754/flt-32/e_powf.c b/sysdeps/ieee754/flt-32/e_powf.c
index d2558ad172..1fa0a0befe 100644
--- a/sysdeps/ieee754/flt-32/e_powf.c
+++ b/sysdeps/ieee754/flt-32/e_powf.c
@@ -84,8 +84,8 @@ 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
-exp2_inline (double_t xd, uint32_t sign_bias)
+static inline float
+exp2_inline (double xd, uint32_t sign_bias)
{
uint64_t ki, ski, t;
double kd, z, r, r2, y, s;
@@ -99,8 +99,7 @@ exp2_inline (double_t xd, uint32_t sign_bias)
# define C __exp2f_data.poly
# define SHIFT __exp2f_data.shift_scaled
/* x = k/N + r with r in [-1/(2N), 1/(2N)] */
- xd = (double) xd; /* Force double precision if FLT_EVAL_METHOD == 2. */
- kd = (double) (xd + SHIFT); /* Rounding to double precision is required. */
+ kd = (double) (xd + SHIFT);
ki = asuint64 (kd);
kd -= SHIFT; /* k/N */
#endif
@@ -180,7 +179,9 @@ __powf (float x, float y)
if (2 * ix == 0 && iy & 0x80000000)
return __math_divzerof (sign_bias);
#endif
- return iy & 0x80000000 ? 1 / x2 : x2;
+ /* Without the barrier some versions of clang hoist the 1/x2 and
+ thus division by zero exception can be signaled spuriously. */
+ return iy & 0x80000000 ? math_opt_barrier (1 / x2) : x2;
}
/* x and y are non-zero finite. */
if (ix & 0x80000000)
@@ -236,7 +237,7 @@ __powf (float x, float y)
return sign_bias ? -0x1.fffffep127 : 0x1.fffffep127;
}
}
- return (float) exp2_inline (ylogx, sign_bias);
+ return exp2_inline (ylogx, sign_bias);
}
#ifndef __powf
strong_alias (__powf, __ieee754_powf)
--
2.43.0
More information about the Libc-alpha
mailing list