about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-12-01 10:37:44 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-12-13 09:08:07 -0300
commit72ab1eaec7e46cdb6c4f37fb687a7a593f93020a (patch)
treef00e454f281e8e40eee79f2ddb81437cb97ea0f6
parent2eb1cd2f47fe6568c539fa105551bb73df8368ec (diff)
downloadglibc-72ab1eaec7e46cdb6c4f37fb687a7a593f93020a.tar.gz
glibc-72ab1eaec7e46cdb6c4f37fb687a7a593f93020a.tar.xz
glibc-72ab1eaec7e46cdb6c4f37fb687a7a593f93020a.zip
math: Add math-use-builtinds-fmax.h
It allows the architecture to use the builtin instead of generic
implementation.
-rw-r--r--math/s_fmax_template.c5
-rw-r--r--sysdeps/generic/math-type-macros-double.h1
-rw-r--r--sysdeps/generic/math-type-macros-float.h1
-rw-r--r--sysdeps/generic/math-type-macros-float128.h1
-rw-r--r--sysdeps/generic/math-type-macros-ldouble.h1
-rw-r--r--sysdeps/generic/math-use-builtins-fmax.h4
-rw-r--r--sysdeps/generic/math-use-builtins.h1
7 files changed, 14 insertions, 0 deletions
diff --git a/math/s_fmax_template.c b/math/s_fmax_template.c
index d817406f04..4a88266e71 100644
--- a/math/s_fmax_template.c
+++ b/math/s_fmax_template.c
@@ -17,10 +17,14 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <math.h>
+#include <math-use-builtins.h>
 
 FLOAT
 M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y)
 {
+#if M_USE_BUILTIN (FMAX)
+  return M_SUF (__builtin_fmax) (x, y);
+#else
   if (isgreaterequal (x, y))
     return x;
   else if (isless (x, y))
@@ -29,6 +33,7 @@ M_DECL_FUNC (__fmax) (FLOAT x, FLOAT y)
     return x + y;
   else
     return isnan (y) ? x : y;
+#endif
 }
 
 declare_mgen_alias (__fmax, fmax);
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
index 8d2d8362cc..e29112d814 100644
--- a/sysdeps/generic/math-type-macros-double.h
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -26,6 +26,7 @@
 #define FLOAT double
 #define CFLOAT _Complex double
 #define M_STRTO_NAN __strtod_nan
+#define M_USE_BUILTIN(c) USE_ ##c ##_BUILTIN
 
 #include <libm-alias-double.h>
 #include <math-nan-payload-double.h>
diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h
index fb84d62909..5ba7615500 100644
--- a/sysdeps/generic/math-type-macros-float.h
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -25,6 +25,7 @@
 #define FLOAT float
 #define CFLOAT _Complex float
 #define M_STRTO_NAN __strtof_nan
+#define M_USE_BUILTIN(c) USE_ ##c ##F_BUILTIN
 
 /* Standard/GNU macro literals do not exist for the float type.  Use
    the double macro constants.  */
diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h
index 5c190606f5..de4de6e555 100644
--- a/sysdeps/generic/math-type-macros-float128.h
+++ b/sysdeps/generic/math-type-macros-float128.h
@@ -24,6 +24,7 @@
 #define M_SUF(c) c ## f128
 #define FLOAT _Float128
 #define M_STRTO_NAN __strtof128_nan
+#define M_USE_BUILTIN(c) USE_ ##c ##F128_BUILTIN
 
 #define CFLOAT __CFLOAT128
 
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h
index a2f282500e..c3edfcea73 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -26,6 +26,7 @@
 #define FLOAT long double
 #define CFLOAT _Complex long double
 #define M_STRTO_NAN __strtold_nan
+#define M_USE_BUILTIN(c) USE_ ##c ##L_BUILTIN
 
 #include <libm-alias-ldouble.h>
 #include <math-nan-payload-ldouble.h>
diff --git a/sysdeps/generic/math-use-builtins-fmax.h b/sysdeps/generic/math-use-builtins-fmax.h
new file mode 100644
index 0000000000..8fc4efca6a
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-fmax.h
@@ -0,0 +1,4 @@
+#define USE_FMAX_BUILTIN 0
+#define USE_FMAXF_BUILTIN 0
+#define USE_FMAXL_BUILTIN 0
+#define USE_FMAXF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h
index 19d2d1cf3c..e07bba242f 100644
--- a/sysdeps/generic/math-use-builtins.h
+++ b/sysdeps/generic/math-use-builtins.h
@@ -34,5 +34,6 @@
 #include <math-use-builtins-copysign.h>
 #include <math-use-builtins-sqrt.h>
 #include <math-use-builtins-fma.h>
+#include <math-use-builtins-fmax.h>
 
 #endif /* MATH_USE_BUILTINS_H  */