From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org,
Paul Zimmermann <Paul.Zimmermann@inria.fr>,
Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Subject: [PATCH v5 08/12] math: Add math-use-builtinds-fmax.h
Date: Tue, 7 Dec 2021 16:03:49 -0300 [thread overview]
Message-ID: <20211207190353.3282666-9-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20211207190353.3282666-1-adhemerval.zanella@linaro.org>
It allows the architecture to use the builtin instead of generic
implementation.
---
math/s_fmax_template.c | 5 +++++
sysdeps/generic/math-type-macros-double.h | 1 +
sysdeps/generic/math-type-macros-float.h | 1 +
sysdeps/generic/math-type-macros-float128.h | 1 +
sysdeps/generic/math-type-macros-ldouble.h | 1 +
sysdeps/generic/math-use-builtins-fmax.h | 4 ++++
sysdeps/generic/math-use-builtins.h | 1 +
7 files changed, 14 insertions(+)
create mode 100644 sysdeps/generic/math-use-builtins-fmax.h
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 */
--
2.32.0
next prev parent reply other threads:[~2021-12-07 19:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 19:03 [PATCH v5 00/12] Improve hypot Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 01/12] math: Simplify hypotf implementation Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 02/12] math: Use an improved algorithm for hypot (dbl-64) Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 03/12] math: Improve hypot performance with FMA Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 04/12] math: Use an improved algorithm for hypotl (ldbl-96) Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 05/12] math: Use an improved algorithm for hypotl (ldbl-128) Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 06/12] i386: Move hypot implementation to C Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 07/12] math: Remove powerpc e_hypot Adhemerval Zanella
2021-12-07 19:42 ` Paul A. Clarke
2021-12-07 19:03 ` Adhemerval Zanella [this message]
2021-12-07 19:03 ` [PATCH v5 09/12] math: Add math-use-builtinds-fmin.h Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 10/12] aarch64: Add math-use-builtins-f{max,min}.h Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 11/12] math: Use fmin/fmax on hypot Adhemerval Zanella
2021-12-07 19:03 ` [PATCH v5 12/12] math: Remove the error handling wrapper from hypot and hypotf Adhemerval Zanella
2021-12-08 5:51 ` [PATCH v5 00/12] Improve hypot Paul Zimmermann
2021-12-10 19:31 ` Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211207190353.3282666-9-adhemerval.zanella@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=Paul.Zimmermann@inria.fr \
--cc=Wilco.Dijkstra@arm.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).