]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Reimplement min_of_type using __MATH_TG.
authorJoseph Myers <joseph@codesourcery.com>
Fri, 4 Aug 2017 21:32:57 +0000 (21:32 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 4 Aug 2017 21:32:57 +0000 (21:32 +0000)
This patch reimplements the libm-internal min_of_type macro to use
__MATH_TG instead of its own local type-generic implementation, so
simplifying the code and reducing the number of different type-generic
implementation variants in use in glibc.

Tested for x86_64.

* sysdeps/generic/math_private.h (__EXPR_FLT128): Remove macro.
(min_of_type_f): New macro.
(min_of_type_): Likewise.
(min_of_type_l): Likewise.
(min_of_type_f128): Likewise.
(min_of_type): Define using __MATH_TG and taking an expression
argument.
(math_check_force_underflow): Pass expression instead of type to
min_of_type.
(math_check_force_underflow_nonneg): Likewise.

ChangeLog
sysdeps/generic/math_private.h

index 0909e4d77a9919f1874922deef8641e7d7ba29ab..7cee9458791b97addaa7a5a333f1388037b30d71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2017-08-04  Joseph Myers  <joseph@codesourcery.com>
+
+       * sysdeps/generic/math_private.h (__EXPR_FLT128): Remove macro.
+       (min_of_type_f): New macro.
+       (min_of_type_): Likewise.
+       (min_of_type_l): Likewise.
+       (min_of_type_f128): Likewise.
+       (min_of_type): Define using __MATH_TG and taking an expression
+       argument.
+       (math_check_force_underflow): Pass expression instead of type to
+       min_of_type.
+       (math_check_force_underflow_nonneg): Likewise.
+
 2017-08-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * sysdeps/x86/cpu-features.h [__ASSEMBLER__]
index f1da7c3f06f757283b0c51bb3bab449b26809f73..4d962e1d09f445cce97a87e1f7d4a3c11e5965fd 100644 (file)
@@ -301,24 +301,14 @@ extern void __docos (double __x, double __dx, double __v[]);
    })
 #endif
 
-#if __HAVE_DISTINCT_FLOAT128
-# define __EXPR_FLT128(x, yes, no)                             \
-  __builtin_choose_expr (__builtin_types_compatible_p          \
-                        (x, long double), no, yes)
-#else
-# define __EXPR_FLT128(x, yes, no) no
-#endif
-
-
 #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x))
 
-#define min_of_type(type) __builtin_choose_expr                \
-  (__builtin_types_compatible_p (type, float),         \
-   FLT_MIN,                                            \
-   __builtin_choose_expr                               \
-   (__builtin_types_compatible_p (type, double),       \
-    DBL_MIN,                                           \
-    __EXPR_FLT128 (type, FLT128_MIN, LDBL_MIN)))
+#define min_of_type_f FLT_MIN
+#define min_of_type_ DBL_MIN
+#define min_of_type_l LDBL_MIN
+#define min_of_type_f128 FLT128_MIN
+
+#define min_of_type(x) __MATH_TG ((x), (__typeof (x)) min_of_type_, )
 
 /* If X (which is not a NaN) is subnormal, force an underflow
    exception.  */
@@ -327,7 +317,7 @@ extern void __docos (double __x, double __dx, double __v[]);
     {                                                          \
       __typeof (x) force_underflow_tmp = (x);                  \
       if (fabs_tg (force_underflow_tmp)                                \
-         < min_of_type (__typeof (force_underflow_tmp)))       \
+         < min_of_type (force_underflow_tmp))                  \
        {                                                       \
          __typeof (force_underflow_tmp) force_underflow_tmp2   \
            = force_underflow_tmp * force_underflow_tmp;        \
@@ -341,7 +331,7 @@ extern void __docos (double __x, double __dx, double __v[]);
     {                                                          \
       __typeof (x) force_underflow_tmp = (x);                  \
       if (force_underflow_tmp                                  \
-         < min_of_type (__typeof (force_underflow_tmp)))       \
+         < min_of_type (force_underflow_tmp))                  \
        {                                                       \
          __typeof (force_underflow_tmp) force_underflow_tmp2   \
            = force_underflow_tmp * force_underflow_tmp;        \