]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Add math-use-builtinds-fmax.h
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 1 Dec 2021 13:37:44 +0000 (10:37 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 13 Dec 2021 12:08:07 +0000 (09:08 -0300)
It allows the architecture to use the builtin instead of generic
implementation.

math/s_fmax_template.c
sysdeps/generic/math-type-macros-double.h
sysdeps/generic/math-type-macros-float.h
sysdeps/generic/math-type-macros-float128.h
sysdeps/generic/math-type-macros-ldouble.h
sysdeps/generic/math-use-builtins-fmax.h [new file with mode: 0644]
sysdeps/generic/math-use-builtins.h

index d817406f04b121cde4fc8ebe0d79f6a12c3306f4..4a88266e711a8efd1e556a53fedf21121617f6ad 100644 (file)
    <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);
index 8d2d8362cc2875bb5ea43507297ed9d856a60b7f..e29112d814667ab71bf4008cd7665dac3f8dabbb 100644 (file)
@@ -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>
index fb84d62909d024a9f08dc92c9d614254efec7618..5ba76155009e1615cb1df1232745a2b402de2f8b 100644 (file)
@@ -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.  */
index 5c190606f52516be77bced7665fb50b16be9fb6b..de4de6e55519224b026e269a8df84ae97e1e3a3a 100644 (file)
@@ -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
 
index a2f282500e55bf6af19b799c200afa39353903fc..c3edfcea7305c7317e6b32d9ae4855242b30c60b 100644 (file)
@@ -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 (file)
index 0000000..8fc4efc
--- /dev/null
@@ -0,0 +1,4 @@
+#define USE_FMAX_BUILTIN 0
+#define USE_FMAXF_BUILTIN 0
+#define USE_FMAXL_BUILTIN 0
+#define USE_FMAXF128_BUILTIN 0
index 19d2d1cf3cd0d1c0a7e44a9beb4fac41d037a527..e07bba242f78286014d5aa10ba5213f4e57acb98 100644 (file)
@@ -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  */