diff --git a/math/s_fmaximum_template.c b/math/s_fmaximum_template.c index ddd7a8443c..d0eb299120 100644 --- a/math/s_fmaximum_template.c +++ b/math/s_fmaximum_template.c @@ -21,12 +21,18 @@ FLOAT M_DECL_FUNC (__fmaximum) (FLOAT x, FLOAT y) { - if (isgreater (x, y)) - return x; - else if (isless (x, y)) - return y; - else if (x == y) - return (M_COPYSIGN (1, x) >= M_COPYSIGN (1, y) ? x : y); + if (__glibc_likely (!isunordered (x, y))) + { +#if M_USE_BUILTIN (FMAX) + return M_SUF (__builtin_fmax) (x, y); +#else + if (isgreater (x, y)) + return x; + else if (isless (x, y)) + return y; + return signbit (x) ? y : x; +#endif + } else return x + y; } diff --git a/math/s_fminimum_template.c b/math/s_fminimum_template.c index b987e5447c..32380e6741 100644 --- a/math/s_fminimum_template.c +++ b/math/s_fminimum_template.c @@ -21,12 +21,18 @@ FLOAT M_DECL_FUNC (__fminimum) (FLOAT x, FLOAT y) { - if (isless (x, y)) - return x; - else if (isgreater (x, y)) - return y; - else if (x == y) - return (M_COPYSIGN (1, x) <= M_COPYSIGN (1, y) ? x : y); + if (__glibc_likely (!isunordered (x, y))) + { +#if M_USE_BUILTIN (FMIN) + return M_SUF (__builtin_fmin) (x, y); +#else + if (isless (x, y)) + return x; + else if (isgreater (x, y)) + return y; + return signbit (x) ? x : y; +#endif + } else return x + y; }