[PATCH v2 5/5] math: Remove the error handling wrapper from fmod and fmodf
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Thu Mar 16 17:21:46 GMT 2023
Hi Adhemerval,
> It shows an small improvement, the results for fmod:
> x86_64 (Ryzen 9) | close-exponents | 16.0244 | 13.119
> aarch64 (N1) | close-exponents | 8.21306 | 5.76138
I wouldn't call gains of 22% on Ryzen and 42% on N1 for the common case small!
> @@ -56,11 +58,13 @@ __ieee754_fmod (double x, double y)
>...
> - if (__glibc_unlikely (hy == 0 || hx >= EXPONENT_MASK || hy > EXPONENT_MASK))
> + if (__glibc_unlikely (is_nan (hx) || is_nan (hy)))
> return (x * y) / (x * y);
> + if (__glibc_unlikely (hy == 0 || is_inf (hx)))
> + return __math_edom ((x * y) / (x * y));
This now requires 4 compares rather than 2 of the previous if statement (as GCC is able
to merge the 2 tests on hy). It's better to keep that and then handle the special cases.
> @@ -59,8 +61,10 @@ __ieee754_fmodf (float x, float y)
>...
>+ if (__glibc_unlikely (hy == 0 || is_inf (hx)))
>+ return __math_edom ((x * y) / (x * y));
__math_edomf?
> diff --git a/sysdeps/ieee754/flt-32/math_config.h b/sysdeps/ieee754/flt-32/math_config.h
>...
>+attribute_hidden float __math_edom (float x);
__math_edomf?
Cheers,
Wilco
More information about the Libc-alpha
mailing list