public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 01/13] math: Decompose math-use-builtins.h
@ 2020-06-09 21:32 Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f} Adhemerval Zanella
                   ` (12 more replies)
  0 siblings, 13 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Each symbol definitions are moved on a separated file and it
cover all symbol type definitions (float, double, long double,
and float128).

It allows to set support for architectures without the boiler
place of copying default values.

Checked with a build on the affected ABIs.
---
 sysdeps/aarch64/fpu/math-use-builtins-ceil.h  |   4 +
 sysdeps/aarch64/fpu/math-use-builtins-floor.h |   4 +
 sysdeps/aarch64/fpu/math-use-builtins-fma.h   |   4 +
 .../aarch64/fpu/math-use-builtins-nearbyint.h |   4 +
 sysdeps/aarch64/fpu/math-use-builtins-rint.h  |   4 +
 sysdeps/aarch64/fpu/math-use-builtins-round.h |   4 +
 sysdeps/aarch64/fpu/math-use-builtins-sqrt.h  |   4 +
 sysdeps/aarch64/fpu/math-use-builtins-trunc.h |   4 +
 sysdeps/aarch64/fpu/math-use-builtins.h       |  71 -----------
 sysdeps/generic/math-use-builtins-ceil.h      |   4 +
 sysdeps/generic/math-use-builtins-copysign.h  |   7 ++
 sysdeps/generic/math-use-builtins-floor.h     |   4 +
 sysdeps/generic/math-use-builtins-fma.h       |   4 +
 sysdeps/generic/math-use-builtins-nearbyint.h |   4 +
 sysdeps/generic/math-use-builtins-rint.h      |   4 +
 sysdeps/generic/math-use-builtins-round.h     |   4 +
 sysdeps/generic/math-use-builtins-sqrt.h      |   4 +
 sysdeps/generic/math-use-builtins-trunc.h     |   4 +
 sysdeps/generic/math-use-builtins.h           |  56 ++-------
 sysdeps/powerpc/fpu/math-use-builtins-fma.h   |   9 ++
 sysdeps/powerpc/fpu/math-use-builtins.h       |  77 ------------
 sysdeps/s390/fpu/math-use-builtins-ceil.h     |  15 +++
 sysdeps/s390/fpu/math-use-builtins-floor.h    |  15 +++
 .../s390/fpu/math-use-builtins-nearbyint.h    |  15 +++
 sysdeps/s390/fpu/math-use-builtins-rint.h     |  15 +++
 sysdeps/s390/fpu/math-use-builtins-round.h    |  15 +++
 sysdeps/s390/fpu/math-use-builtins-trunc.h    |  15 +++
 sysdeps/s390/fpu/math-use-builtins.h          | 119 ------------------
 28 files changed, 181 insertions(+), 312 deletions(-)
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-ceil.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-floor.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-fma.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-nearbyint.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-rint.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-round.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-sqrt.h
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins-trunc.h
 delete mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
 create mode 100644 sysdeps/generic/math-use-builtins-ceil.h
 create mode 100644 sysdeps/generic/math-use-builtins-copysign.h
 create mode 100644 sysdeps/generic/math-use-builtins-floor.h
 create mode 100644 sysdeps/generic/math-use-builtins-fma.h
 create mode 100644 sysdeps/generic/math-use-builtins-nearbyint.h
 create mode 100644 sysdeps/generic/math-use-builtins-rint.h
 create mode 100644 sysdeps/generic/math-use-builtins-round.h
 create mode 100644 sysdeps/generic/math-use-builtins-sqrt.h
 create mode 100644 sysdeps/generic/math-use-builtins-trunc.h
 create mode 100644 sysdeps/powerpc/fpu/math-use-builtins-fma.h
 delete mode 100644 sysdeps/powerpc/fpu/math-use-builtins.h
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-ceil.h
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-floor.h
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-nearbyint.h
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-rint.h
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-round.h
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-trunc.h
 delete mode 100644 sysdeps/s390/fpu/math-use-builtins.h

diff --git a/sysdeps/aarch64/fpu/math-use-builtins-ceil.h b/sysdeps/aarch64/fpu/math-use-builtins-ceil.h
new file mode 100644
index 0000000000..17d6452e51
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-ceil.h
@@ -0,0 +1,4 @@
+#define USE_CEIL_BUILTIN 1
+#define USE_CEILF_BUILTIN 1
+#define USE_CEILL_BUILTIN 0
+#define USE_CEILF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-floor.h b/sysdeps/aarch64/fpu/math-use-builtins-floor.h
new file mode 100644
index 0000000000..553c0674af
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-floor.h
@@ -0,0 +1,4 @@
+#define USE_FLOOR_BUILTIN 1
+#define USE_FLOORF_BUILTIN 1
+#define USE_FLOORL_BUILTIN 0
+#define USE_FLOORF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-fma.h b/sysdeps/aarch64/fpu/math-use-builtins-fma.h
new file mode 100644
index 0000000000..eede75aa41
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-fma.h
@@ -0,0 +1,4 @@
+#define USE_FMA_BUILTIN 1
+#define USE_FMAF_BUILTIN 1
+#define USE_FMAL_BUILTIN 0
+#define USE_FMAF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-nearbyint.h b/sysdeps/aarch64/fpu/math-use-builtins-nearbyint.h
new file mode 100644
index 0000000000..a2590c920f
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-nearbyint.h
@@ -0,0 +1,4 @@
+#define USE_NEARBYINT_BUILTIN 1
+#define USE_NEARBYINTF_BUILTIN 1
+#define USE_NEARBYINTL_BUILTIN 0
+#define USE_NEARBYINTF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-rint.h b/sysdeps/aarch64/fpu/math-use-builtins-rint.h
new file mode 100644
index 0000000000..45c3307692
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-rint.h
@@ -0,0 +1,4 @@
+#define USE_RINT_BUILTIN 1
+#define USE_RINTF_BUILTIN 1
+#define USE_RINTL_BUILTIN 0
+#define USE_RINTF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-round.h b/sysdeps/aarch64/fpu/math-use-builtins-round.h
new file mode 100644
index 0000000000..f6083d7d0a
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-round.h
@@ -0,0 +1,4 @@
+#define USE_ROUND_BUILTIN 1
+#define USE_ROUNDF_BUILTIN 1
+#define USE_ROUNDL_BUILTIN 0
+#define USE_ROUNDF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-sqrt.h b/sysdeps/aarch64/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e94c915ba6
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins-trunc.h b/sysdeps/aarch64/fpu/math-use-builtins-trunc.h
new file mode 100644
index 0000000000..4fc6da42b6
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins-trunc.h
@@ -0,0 +1,4 @@
+#define USE_TRUNC_BUILTIN 1
+#define USE_TRUNCF_BUILTIN 1
+#define USE_TRUNCL_BUILTIN 0
+#define USE_TRUNCF128_BUILTIN 0
diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h b/sysdeps/aarch64/fpu/math-use-builtins.h
deleted file mode 100644
index 50a1ba0db5..0000000000
--- a/sysdeps/aarch64/fpu/math-use-builtins.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Using math gcc builtins instead of generic implementation.  aarch64 version.
-   Copyright (C) 2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef MATH_USE_BUILTINS_H
-#define MATH_USE_BUILTINS_H	1
-
-#include <features.h> /* For __GNUC_PREREQ.  */
-
-/* Define these macros to 1 to use __builtin_xyz instead of the
-   generic implementation.  */
-#define USE_NEARBYINT_BUILTIN 1
-#define USE_NEARBYINTF_BUILTIN 1
-#define USE_NEARBYINTL_BUILTIN 0
-#define USE_NEARBYINTF128_BUILTIN 0
-
-#define USE_RINT_BUILTIN 1
-#define USE_RINTF_BUILTIN 1
-#define USE_RINTL_BUILTIN 0
-#define USE_RINTF128_BUILTIN 0
-
-#define USE_FLOOR_BUILTIN 1
-#define USE_FLOORF_BUILTIN 1
-#define USE_FLOORL_BUILTIN 0
-#define USE_FLOORF128_BUILTIN 0
-
-#define USE_CEIL_BUILTIN 1
-#define USE_CEILF_BUILTIN 1
-#define USE_CEILL_BUILTIN 0
-#define USE_CEILF128_BUILTIN 0
-
-#define USE_TRUNC_BUILTIN 1
-#define USE_TRUNCF_BUILTIN 1
-#define USE_TRUNCL_BUILTIN 0
-#define USE_TRUNCF128_BUILTIN 0
-
-#define USE_ROUND_BUILTIN 1
-#define USE_ROUNDF_BUILTIN 1
-#define USE_ROUNDL_BUILTIN 0
-#define USE_ROUNDF128_BUILTIN 0
-
-#define USE_COPYSIGNL_BUILTIN 1
-#if __GNUC_PREREQ (7, 0)
-# define USE_COPYSIGNF128_BUILTIN 1
-#else
-# define USE_COPYSIGNF128_BUILTIN 0
-#endif
-
-#define USE_SQRT_BUILTIN 1
-#define USE_SQRTF_BUILTIN 1
-
-#define USE_FMA_BUILTIN 1
-#define USE_FMAF_BUILTIN 1
-#define USE_FMAL_BUILTIN 0
-#define USE_FMAF128_BUILTIN 0
-
-#endif
diff --git a/sysdeps/generic/math-use-builtins-ceil.h b/sysdeps/generic/math-use-builtins-ceil.h
new file mode 100644
index 0000000000..0698033493
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-ceil.h
@@ -0,0 +1,4 @@
+#define USE_CEIL_BUILTIN 0
+#define USE_CEILF_BUILTIN 0
+#define USE_CEILL_BUILTIN 0
+#define USE_CEILF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-copysign.h b/sysdeps/generic/math-use-builtins-copysign.h
new file mode 100644
index 0000000000..3cf9bbe1fd
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-copysign.h
@@ -0,0 +1,7 @@
+/* Generic implementations for float and double always use the __builtin.  */
+#define USE_COPYSIGNL_BUILTIN 1
+#if __GNUC_PREREQ (7, 0)
+# define USE_COPYSIGNF128_BUILTIN 1
+#else
+# define USE_COPYSIGNF128_BUILTIN 0
+#endif
diff --git a/sysdeps/generic/math-use-builtins-floor.h b/sysdeps/generic/math-use-builtins-floor.h
new file mode 100644
index 0000000000..b0858d9eda
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-floor.h
@@ -0,0 +1,4 @@
+#define USE_FLOOR_BUILTIN 0
+#define USE_FLOORF_BUILTIN 0
+#define USE_FLOORL_BUILTIN 0
+#define USE_FLOORF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-fma.h b/sysdeps/generic/math-use-builtins-fma.h
new file mode 100644
index 0000000000..51dcb6a240
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-fma.h
@@ -0,0 +1,4 @@
+#define USE_FMA_BUILTIN 0
+#define USE_FMAF_BUILTIN 0
+#define USE_FMAL_BUILTIN 0
+#define USE_FMAF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-nearbyint.h b/sysdeps/generic/math-use-builtins-nearbyint.h
new file mode 100644
index 0000000000..ab453532b0
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-nearbyint.h
@@ -0,0 +1,4 @@
+#define USE_NEARBYINT_BUILTIN 0
+#define USE_NEARBYINTF_BUILTIN 0
+#define USE_NEARBYINTL_BUILTIN 0
+#define USE_NEARBYINTF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-rint.h b/sysdeps/generic/math-use-builtins-rint.h
new file mode 100644
index 0000000000..24793757f6
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-rint.h
@@ -0,0 +1,4 @@
+#define USE_RINT_BUILTIN 0
+#define USE_RINTF_BUILTIN 0
+#define USE_RINTL_BUILTIN 0
+#define USE_RINTF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-round.h b/sysdeps/generic/math-use-builtins-round.h
new file mode 100644
index 0000000000..de2dce1f5b
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-round.h
@@ -0,0 +1,4 @@
+#define USE_ROUND_BUILTIN 0
+#define USE_ROUNDF_BUILTIN 0
+#define USE_ROUNDL_BUILTIN 0
+#define USE_ROUNDF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-sqrt.h b/sysdeps/generic/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..7b4fed380f
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 0
+#define USE_SQRTF_BUILTIN 0
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins-trunc.h b/sysdeps/generic/math-use-builtins-trunc.h
new file mode 100644
index 0000000000..59e6d97d13
--- /dev/null
+++ b/sysdeps/generic/math-use-builtins-trunc.h
@@ -0,0 +1,4 @@
+#define USE_TRUNC_BUILTIN 0
+#define USE_TRUNCF_BUILTIN 0
+#define USE_TRUNCL_BUILTIN 0
+#define USE_TRUNCF128_BUILTIN 0
diff --git a/sysdeps/generic/math-use-builtins.h b/sysdeps/generic/math-use-builtins.h
index cf25ed8a21..78d6146762 100644
--- a/sysdeps/generic/math-use-builtins.h
+++ b/sysdeps/generic/math-use-builtins.h
@@ -23,49 +23,15 @@
 
 /* Define these macros to 1 to use __builtin_xyz instead of the
    generic implementation.  */
-#define USE_NEARBYINT_BUILTIN 0
-#define USE_NEARBYINTF_BUILTIN 0
-#define USE_NEARBYINTL_BUILTIN 0
-#define USE_NEARBYINTF128_BUILTIN 0
 
-#define USE_RINT_BUILTIN 0
-#define USE_RINTF_BUILTIN 0
-#define USE_RINTL_BUILTIN 0
-#define USE_RINTF128_BUILTIN 0
-
-#define USE_FLOOR_BUILTIN 0
-#define USE_FLOORF_BUILTIN 0
-#define USE_FLOORL_BUILTIN 0
-#define USE_FLOORF128_BUILTIN 0
-
-#define USE_CEIL_BUILTIN 0
-#define USE_CEILF_BUILTIN 0
-#define USE_CEILL_BUILTIN 0
-#define USE_CEILF128_BUILTIN 0
-
-#define USE_TRUNC_BUILTIN 0
-#define USE_TRUNCF_BUILTIN 0
-#define USE_TRUNCL_BUILTIN 0
-#define USE_TRUNCF128_BUILTIN 0
-
-#define USE_ROUND_BUILTIN 0
-#define USE_ROUNDF_BUILTIN 0
-#define USE_ROUNDL_BUILTIN 0
-#define USE_ROUNDF128_BUILTIN 0
-
-#define USE_COPYSIGNL_BUILTIN 1
-#if __GNUC_PREREQ (7, 0)
-# define USE_COPYSIGNF128_BUILTIN 1
-#else
-# define USE_COPYSIGNF128_BUILTIN 0
-#endif
-
-#define USE_SQRT_BUILTIN 0
-#define USE_SQRTF_BUILTIN 0
-
-#define USE_FMA_BUILTIN 0
-#define USE_FMAF_BUILTIN 0
-#define USE_FMAL_BUILTIN 0
-#define USE_FMAF128_BUILTIN 0
-
-#endif /* math-use-builtins.h */
+#include <math-use-builtins-nearbyint.h>
+#include <math-use-builtins-rint.h>
+#include <math-use-builtins-floor.h>
+#include <math-use-builtins-ceil.h>
+#include <math-use-builtins-trunc.h>
+#include <math-use-builtins-round.h>
+#include <math-use-builtins-copysign.h>
+#include <math-use-builtins-sqrt.h>
+#include <math-use-builtins-fma.h>
+
+#endif /* MATH_USE_BUILTINS_H  */
diff --git a/sysdeps/powerpc/fpu/math-use-builtins-fma.h b/sysdeps/powerpc/fpu/math-use-builtins-fma.h
new file mode 100644
index 0000000000..5652e55185
--- /dev/null
+++ b/sysdeps/powerpc/fpu/math-use-builtins-fma.h
@@ -0,0 +1,9 @@
+#define USE_FMA_BUILTIN 1
+#define USE_FMAF_BUILTIN 1
+#define USE_FMAL_BUILTIN 0
+/* This is not available for P8 or BE targets.  */
+#ifdef __FP_FAST_FMAF128
+# define USE_FMAF128_BUILTIN 1
+#else
+# define USE_FMAF128_BUILTIN 0
+#endif
diff --git a/sysdeps/powerpc/fpu/math-use-builtins.h b/sysdeps/powerpc/fpu/math-use-builtins.h
deleted file mode 100644
index 72e28ec9cc..0000000000
--- a/sysdeps/powerpc/fpu/math-use-builtins.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Using math gcc builtins instead of generic implementation.  PowerPC version.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef MATH_USE_BUILTINS_H
-#define MATH_USE_BUILTINS_H	1
-
-#include <features.h> /* For __GNUC_PREREQ.  */
-
-/* Define these macros to 1 to use __builtin_xyz instead of the
-   generic implementation.  */
-#define USE_NEARBYINT_BUILTIN 0
-#define USE_NEARBYINTF_BUILTIN 0
-#define USE_NEARBYINTL_BUILTIN 0
-#define USE_NEARBYINTF128_BUILTIN 0
-
-#define USE_RINT_BUILTIN 0
-#define USE_RINTF_BUILTIN 0
-#define USE_RINTL_BUILTIN 0
-#define USE_RINTF128_BUILTIN 0
-
-#define USE_FLOOR_BUILTIN 0
-#define USE_FLOORF_BUILTIN 0
-#define USE_FLOORL_BUILTIN 0
-#define USE_FLOORF128_BUILTIN 0
-
-#define USE_CEIL_BUILTIN 0
-#define USE_CEILF_BUILTIN 0
-#define USE_CEILL_BUILTIN 0
-#define USE_CEILF128_BUILTIN 0
-
-#define USE_TRUNC_BUILTIN 0
-#define USE_TRUNCF_BUILTIN 0
-#define USE_TRUNCL_BUILTIN 0
-#define USE_TRUNCF128_BUILTIN 0
-
-#define USE_ROUND_BUILTIN 0
-#define USE_ROUNDF_BUILTIN 0
-#define USE_ROUNDL_BUILTIN 0
-#define USE_ROUNDF128_BUILTIN 0
-
-#define USE_COPYSIGNL_BUILTIN 1
-#if __GNUC_PREREQ (7, 0)
-# define USE_COPYSIGNF128_BUILTIN 1
-#else
-# define USE_COPYSIGNF128_BUILTIN 0
-#endif
-
-#define USE_SQRT_BUILTIN 0
-#define USE_SQRTF_BUILTIN 0
-
-#define USE_FMA_BUILTIN 1
-#define USE_FMAF_BUILTIN 1
-#define USE_FMAL_BUILTIN 0
-
-/* This is not available for P8 or BE targets.  */
-#ifdef __FP_FAST_FMAF128
-# define USE_FMAF128_BUILTIN 1
-#else
-# define USE_FMAF128_BUILTIN 0
-#endif
-
-#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins-ceil.h b/sysdeps/s390/fpu/math-use-builtins-ceil.h
new file mode 100644
index 0000000000..bec147a17f
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-ceil.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define USE_CEIL_BUILTIN 1
+# define USE_CEILF_BUILTIN 1
+# define USE_CEILL_BUILTIN 1
+# if __GNUC_PREREQ (8, 0)
+#  define USE_CEILF128_BUILTIN 1
+# else
+#  define USE_CEILF128_BUILTIN 0
+# endif
+#else
+# define USE_CEIL_BUILTIN 0
+# define USE_CEILF_BUILTIN 0
+# define USE_CEILL_BUILTIN 0
+# define USE_CEILF128_BUILTIN 0
+#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins-floor.h b/sysdeps/s390/fpu/math-use-builtins-floor.h
new file mode 100644
index 0000000000..6c034e03bb
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-floor.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define USE_FLOOR_BUILTIN 1
+# define USE_FLOORF_BUILTIN 1
+# define USE_FLOORL_BUILTIN 1
+# if __GNUC_PREREQ (8, 0)
+#  define USE_FLOORF128_BUILTIN 1
+# else
+#  define USE_FLOORF128_BUILTIN 0
+# endif
+#else
+# define USE_FLOOR_BUILTIN 0
+# define USE_FLOORF_BUILTIN 0
+# define USE_FLOORL_BUILTIN 0
+# define USE_FLOORF128_BUILTIN 0
+#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins-nearbyint.h b/sysdeps/s390/fpu/math-use-builtins-nearbyint.h
new file mode 100644
index 0000000000..2f3936e362
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-nearbyint.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define USE_NEARBYINT_BUILTIN 1
+# define USE_NEARBYINTF_BUILTIN 1
+# define USE_NEARBYINTL_BUILTIN 1
+# if __GNUC_PREREQ (8, 0)
+#  define USE_NEARBYINTF128_BUILTIN 1
+# else
+#  define USE_NEARBYINTF128_BUILTIN 0
+# endif
+#else
+# define USE_NEARBYINT_BUILTIN 0
+# define USE_NEARBYINTF_BUILTIN 0
+# define USE_NEARBYINTL_BUILTIN 0
+# define USE_NEARBYINTF128_BUILTIN 0
+#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins-rint.h b/sysdeps/s390/fpu/math-use-builtins-rint.h
new file mode 100644
index 0000000000..2ba16eeaec
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-rint.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define USE_RINT_BUILTIN 1
+# define USE_RINTF_BUILTIN 1
+# define USE_RINTL_BUILTIN 1
+# if __GNUC_PREREQ (8, 0)
+#  define USE_RINTF128_BUILTIN 1
+# else
+#  define USE_RINTF128_BUILTIN 0
+# endif
+#else
+# define USE_RINT_BUILTIN 0
+# define USE_RINTF_BUILTIN 0
+# define USE_RINTL_BUILTIN 0
+# define USE_RINTF128_BUILTIN 0
+#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins-round.h b/sysdeps/s390/fpu/math-use-builtins-round.h
new file mode 100644
index 0000000000..d92daa9654
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-round.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define USE_ROUND_BUILTIN 1
+# define USE_ROUNDF_BUILTIN 1
+# define USE_ROUNDL_BUILTIN 1
+# if __GNUC_PREREQ (8, 0)
+#  define USE_ROUNDF128_BUILTIN 1
+# else
+#  define USE_ROUNDF128_BUILTIN 0
+# endif
+#else
+# define USE_ROUND_BUILTIN 0
+# define USE_ROUNDF_BUILTIN 0
+# define USE_ROUNDL_BUILTIN 0
+# define USE_ROUNDF128_BUILTIN 0
+#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins-trunc.h b/sysdeps/s390/fpu/math-use-builtins-trunc.h
new file mode 100644
index 0000000000..9b5b02de41
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-trunc.h
@@ -0,0 +1,15 @@
+#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
+# define USE_TRUNC_BUILTIN 1
+# define USE_TRUNCF_BUILTIN 1
+# define USE_TRUNCL_BUILTIN 1
+# if __GNUC_PREREQ (8, 0)
+#  define USE_TRUNCF128_BUILTIN 1
+# else
+#  define USE_TRUNCF128_BUILTIN 0
+# endif
+#else
+# define USE_TRUNC_BUILTIN 0
+# define USE_TRUNCF_BUILTIN 0
+# define USE_TRUNCL_BUILTIN 0
+# define USE_TRUNCF128_BUILTIN 0
+#endif
diff --git a/sysdeps/s390/fpu/math-use-builtins.h b/sysdeps/s390/fpu/math-use-builtins.h
deleted file mode 100644
index 3a80f86b2e..0000000000
--- a/sysdeps/s390/fpu/math-use-builtins.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Using math gcc builtins instead of generic implementation.  s390/s390x version.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef MATH_USE_BUILTINS_S390_H
-#define MATH_USE_BUILTINS_S390_H	1
-
-#ifdef HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT
-
-# include <features.h> /* For __GNUC_PREREQ.  */
-
-/* GCC emits the z196 zarch "load fp integer" instructions for these
-   builtins if build with at least --march=z196 -mzarch.  Otherwise a
-   function call to libc is emitted.  */
-# define USE_NEARBYINT_BUILTIN 1
-# define USE_NEARBYINTF_BUILTIN 1
-# define USE_NEARBYINTL_BUILTIN 1
-
-# define USE_RINT_BUILTIN 1
-# define USE_RINTF_BUILTIN 1
-# define USE_RINTL_BUILTIN 1
-
-# define USE_FLOOR_BUILTIN 1
-# define USE_FLOORF_BUILTIN 1
-# define USE_FLOORL_BUILTIN 1
-
-# define USE_CEIL_BUILTIN 1
-# define USE_CEILF_BUILTIN 1
-# define USE_CEILL_BUILTIN 1
-
-# define USE_TRUNC_BUILTIN 1
-# define USE_TRUNCF_BUILTIN 1
-# define USE_TRUNCL_BUILTIN 1
-
-# define USE_ROUND_BUILTIN 1
-# define USE_ROUNDF_BUILTIN 1
-# define USE_ROUNDL_BUILTIN 1
-
-# if __GNUC_PREREQ (8, 0)
-#  define USE_NEARBYINTF128_BUILTIN 1
-#  define USE_RINTF128_BUILTIN 1
-#  define USE_FLOORF128_BUILTIN 1
-#  define USE_CEILF128_BUILTIN 1
-#  define USE_TRUNCF128_BUILTIN 1
-#  define USE_ROUNDF128_BUILTIN 1
-# else
-#  define USE_NEARBYINTF128_BUILTIN 0
-#  define USE_RINTF128_BUILTIN 0
-#  define USE_FLOORF128_BUILTIN 0
-#  define USE_CEILF128_BUILTIN 0
-#  define USE_TRUNCF128_BUILTIN 0
-#  define USE_ROUNDF128_BUILTIN 0
-# endif
-
-#else
-
-/* Disable the builtins if we do not have the z196 zarch instructions.  */
-# define USE_NEARBYINT_BUILTIN 0
-# define USE_NEARBYINTF_BUILTIN 0
-# define USE_NEARBYINTL_BUILTIN 0
-# define USE_NEARBYINTF128_BUILTIN 0
-
-# define USE_RINT_BUILTIN 0
-# define USE_RINTF_BUILTIN 0
-# define USE_RINTL_BUILTIN 0
-# define USE_RINTF128_BUILTIN 0
-
-# define USE_FLOOR_BUILTIN 0
-# define USE_FLOORF_BUILTIN 0
-# define USE_FLOORL_BUILTIN 0
-# define USE_FLOORF128_BUILTIN 0
-
-# define USE_CEIL_BUILTIN 0
-# define USE_CEILF_BUILTIN 0
-# define USE_CEILL_BUILTIN 0
-# define USE_CEILF128_BUILTIN 0
-
-# define USE_TRUNC_BUILTIN 0
-# define USE_TRUNCF_BUILTIN 0
-# define USE_TRUNCL_BUILTIN 0
-# define USE_TRUNCF128_BUILTIN 0
-
-# define USE_ROUND_BUILTIN 0
-# define USE_ROUNDF_BUILTIN 0
-# define USE_ROUNDL_BUILTIN 0
-# define USE_ROUNDF128_BUILTIN 0
-
-#endif /* ! HAVE_S390_MIN_Z196_ZARCH_ASM_SUPPORT  */
-
-#define USE_COPYSIGNL_BUILTIN 1
-#if __GNUC_PREREQ (7, 0)
-# define USE_COPYSIGNF128_BUILTIN 1
-#else
-# define USE_COPYSIGNF128_BUILTIN 0
-#endif
-
-#define USE_SQRT_BUILTIN 0
-#define USE_SQRTF_BUILTIN 0
-
-#define USE_FMA_BUILTIN 0
-#define USE_FMAF_BUILTIN 0
-#define USE_FMAL_BUILTIN 0
-#define USE_FMAF128_BUILTIN 0
-
-#endif /* math-use-builtins.h */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f}
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-10 10:15   ` Szabolcs Nagy
  2020-06-09 21:32 ` [PATCH 03/13] s390x: Use fma{f} builtin Adhemerval Zanella
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

The define is already set on the math-use-builtins-ceil.h, the patch
just removes the implementations (it was missed on c9feb1be93).

Checked on aarch64-linux-gnu.
---
 sysdeps/aarch64/fpu/s_ceil.c  | 29 -----------------------------
 sysdeps/aarch64/fpu/s_ceilf.c | 29 -----------------------------
 2 files changed, 58 deletions(-)
 delete mode 100644 sysdeps/aarch64/fpu/s_ceil.c
 delete mode 100644 sysdeps/aarch64/fpu/s_ceilf.c

diff --git a/sysdeps/aarch64/fpu/s_ceil.c b/sysdeps/aarch64/fpu/s_ceil.c
deleted file mode 100644
index f3cefdc824..0000000000
--- a/sysdeps/aarch64/fpu/s_ceil.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-#include <math.h>
-#include <libm-alias-double.h>
-
-double
-__ceil (double x)
-{
-  return __builtin_ceil (x);
-}
-
-libm_alias_double (__ceil, ceil)
diff --git a/sysdeps/aarch64/fpu/s_ceilf.c b/sysdeps/aarch64/fpu/s_ceilf.c
deleted file mode 100644
index 1cde85fbaa..0000000000
--- a/sysdeps/aarch64/fpu/s_ceilf.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#define NO_MATH_REDIRECT
-#include <math.h>
-#include <libm-alias-float.h>
-
-float
-__ceilf (float x)
-{
-  return __builtin_ceilf (x);
-}
-
-libm_alias_float (__ceil, ceil)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 03/13] s390x: Use fma{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f} Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-16 10:13   ` Stefan Liebler
  2020-06-09 21:32 ` [PATCH 04/13] powerpc: Use sqrt{f} builtin Adhemerval Zanella
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Checked on s390x-linux-gnu.
---
 sysdeps/s390/fpu/math-use-builtins-fma.h |  4 +++
 sysdeps/s390/fpu/s_fma.c                 | 32 ------------------------
 sysdeps/s390/fpu/s_fmaf.c                | 32 ------------------------
 3 files changed, 4 insertions(+), 64 deletions(-)
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-fma.h
 delete mode 100644 sysdeps/s390/fpu/s_fma.c
 delete mode 100644 sysdeps/s390/fpu/s_fmaf.c

diff --git a/sysdeps/s390/fpu/math-use-builtins-fma.h b/sysdeps/s390/fpu/math-use-builtins-fma.h
new file mode 100644
index 0000000000..eede75aa41
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-fma.h
@@ -0,0 +1,4 @@
+#define USE_FMA_BUILTIN 1
+#define USE_FMAF_BUILTIN 1
+#define USE_FMAL_BUILTIN 0
+#define USE_FMAF128_BUILTIN 0
diff --git a/sysdeps/s390/fpu/s_fma.c b/sysdeps/s390/fpu/s_fma.c
deleted file mode 100644
index ae924d05e8..0000000000
--- a/sysdeps/s390/fpu/s_fma.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Compute x * y + z as ternary operation.  S/390 version.
-   Copyright (C) 2010-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <libm-alias-double.h>
-
-double
-__fma (double x, double y, double z)
-{
-  double r;
-  __asm__ ("madbr %0,%1,%2" : "=f" (r) : "%f" (x), "fR" (y), "0" (z));
-  return r;
-}
-#ifndef __fma
-libm_alias_double (__fma, fma)
-#endif
diff --git a/sysdeps/s390/fpu/s_fmaf.c b/sysdeps/s390/fpu/s_fmaf.c
deleted file mode 100644
index 9e5bc533b8..0000000000
--- a/sysdeps/s390/fpu/s_fmaf.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Compute x * y + z as ternary operation.  S/390 version.
-   Copyright (C) 2010-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <libm-alias-float.h>
-
-float
-__fmaf (float x, float y, float z)
-{
-  float r;
-  __asm__ ("maebr %0,%1,%2" : "=f" (r) : "%f" (x), "fR" (y), "0" (z));
-  return r;
-}
-#ifndef __fmaf
-libm_alias_float (__fma, fma)
-#endif
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 04/13] powerpc: Use sqrt{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f} Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 03/13] s390x: Use fma{f} builtin Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-10 14:22   ` Paul A. Clarke
  2020-06-09 21:32 ` [PATCH 05/13] x86_64: Use builtin sqrt{f,l} Adhemerval Zanella
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

The powerpc sqrt implementation is also simplified:

  - the static constants are open coded within the implementation.
  - for !USE_SQRT_BUILTIN the function is implemented directly on
    __ieee754_sqrt (it avoid an superflous extra jump).

Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.
---
 sysdeps/powerpc/fpu/e_sqrt.c                 | 57 ++++++--------------
 sysdeps/powerpc/fpu/e_sqrtf.c                | 56 ++++++-------------
 sysdeps/powerpc/fpu/math-use-builtins-sqrt.h |  9 ++++
 3 files changed, 42 insertions(+), 80 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/math-use-builtins-sqrt.h

diff --git a/sysdeps/powerpc/fpu/e_sqrt.c b/sysdeps/powerpc/fpu/e_sqrt.c
index a47f77966f..505ae72339 100644
--- a/sysdeps/powerpc/fpu/e_sqrt.c
+++ b/sysdeps/powerpc/fpu/e_sqrt.c
@@ -18,22 +18,16 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <fenv.h>
 #include <fenv_libc.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <sysdep.h>
-#include <ldsodefs.h>
 #include <libm-alias-finite.h>
+#include <math-use-builtins.h>
 
-#ifndef _ARCH_PPCSQ
-static const double almost_half = 0.5000000000000001;	/* 0.5 + 2^-53 */
-static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 };
-static const ieee_float_shape_type a_inf = {.word = 0x7f800000 };
-static const float two108 = 3.245185536584267269e+32;
-static const float twom54 = 5.551115123125782702e-17;
-extern const float __t_sqrt[1024];
-
+double
+__ieee754_sqrt (double x)
+{
+#if USE_SQRT_BUILTIN
+  return __builtin_sqrt (x);
+#else
 /* The method is based on a description in
    Computation of elementary functions on the IBM RISC System/6000 processor,
    P. W. Markstein, IBM J. Res. Develop, 34(1) 1990.
@@ -48,10 +42,7 @@ extern const float __t_sqrt[1024];
    generated guesses (which mostly runs on the integer unit, while the
    Newton-Raphson is running on the FPU).  */
 
-double
-__slow_ieee754_sqrt (double x)
-{
-  const float inf = a_inf.value;
+  extern const float __t_sqrt[1024];
 
   if (x > 0)
     {
@@ -60,7 +51,7 @@ __slow_ieee754_sqrt (double x)
       ieee_double_shape_type ew_u;
       ieee_double_shape_type iw_u;
       ew_u.value = (x);
-      if (x != inf)
+      if (x != INFINITY)
 	{
 	  /* Variables named starting with 's' exist in the
 	     argument-reduced space, so that 2 > sx >= 0.5,
@@ -112,7 +103,7 @@ __slow_ieee754_sqrt (double x)
 	  INSERT_WORDS (fsg, fsgi, 0);
 	  iw_u.parts.msw = fsgi;
 	  iw_u.parts.lsw = (0);
-	  e = -__builtin_fma (sy, sg, -almost_half);
+	  e = -__builtin_fma (sy, sg, -0x1.0000000000001p-1);
 	  sd = -__builtin_fma (sg, sg, -sx);
 	  if ((xi0 & 0x7ff00000) == 0)
 	    goto denorm;
@@ -122,7 +113,7 @@ __slow_ieee754_sqrt (double x)
 	  sy2 = sy + sy;
 	  /* complete the INSERT_WORDS (fsg, fsgi, 0) operation.  */
 	  fsg = iw_u.value;
-	  e = -__builtin_fma (sy, sg, -almost_half);
+	  e = -__builtin_fma (sy, sg, -0x1.0000000000001p-1);
 	  sd = -__builtin_fma (sg, sg, -sx);
 	  sy = __builtin_fma (e, sy2, sy);
 	  shx = sx * fsg;
@@ -131,7 +122,7 @@ __slow_ieee754_sqrt (double x)
 						   rounded incorrectly.  */
 	  sy2 = sy + sy;
 	  g = sg * fsg;
-	  e = -__builtin_fma (sy, sg, -almost_half);
+	  e = -__builtin_fma (sy, sg, -0x1.0000000000001p-1);
 	  d = -__builtin_fma (g, sg, -shx);
 	  sy = __builtin_fma (e, sy2, sy);
 	  fesetenv_register (fe);
@@ -140,38 +131,24 @@ __slow_ieee754_sqrt (double x)
 	  /* For denormalised numbers, we normalise, calculate the
 	     square root, and return an adjusted result.  */
 	  fesetenv_register (fe);
-	  return __slow_ieee754_sqrt (x * two108) * twom54;
+	  return __ieee754_sqrt (x * 0x1p+108f) * 0x1p-54f;
 	}
     }
   else if (x < 0)
     {
       /* For some reason, some PowerPC32 processors don't implement
 	 FE_INVALID_SQRT.  */
-#ifdef FE_INVALID_SQRT
+# ifdef FE_INVALID_SQRT
       __feraiseexcept (FE_INVALID_SQRT);
 
       fenv_union_t u = { .fenv = fegetenv_register () };
       if ((u.l & FE_INVALID) == 0)
-#endif
+# endif
 	__feraiseexcept (FE_INVALID);
-      x = a_nan.value;
+      x = NAN;
     }
   return f_wash (x);
+#endif /* USE_SQRT_BUILTIN  */
 }
-#endif /* _ARCH_PPCSQ  */
 
-#undef __ieee754_sqrt
-double
-__ieee754_sqrt (double x)
-{
-  double z;
-
-#ifdef _ARCH_PPCSQ
-  asm ("fsqrt %0,%1\n" :"=f" (z):"f" (x));
-#else
-  z = __slow_ieee754_sqrt (x);
-#endif
-
-  return z;
-}
 libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/powerpc/fpu/e_sqrtf.c b/sysdeps/powerpc/fpu/e_sqrtf.c
index f119dcf5d9..ae76bb1e10 100644
--- a/sysdeps/powerpc/fpu/e_sqrtf.c
+++ b/sysdeps/powerpc/fpu/e_sqrtf.c
@@ -18,22 +18,16 @@
 
 #include <math.h>
 #include <math_private.h>
-#include <fenv.h>
 #include <fenv_libc.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <sysdep.h>
-#include <ldsodefs.h>
 #include <libm-alias-finite.h>
+#include <math-use-builtins.h>
 
-#ifndef _ARCH_PPCSQ
-static const float almost_half = 0.50000006;	/* 0.5 + 2^-24 */
-static const ieee_float_shape_type a_nan = {.word = 0x7fc00000 };
-static const ieee_float_shape_type a_inf = {.word = 0x7f800000 };
-static const float two48 = 281474976710656.0;
-static const float twom24 = 5.9604644775390625e-8;
-extern const float __t_sqrt[1024];
-
+float
+__ieee754_sqrtf (float x)
+{
+#if USE_SQRTF_BUILTIN
+  return __builtin_sqrtf (x);
+#else
 /* The method is based on a description in
    Computation of elementary functions on the IBM RISC System/6000 processor,
    P. W. Markstein, IBM J. Res. Develop, 34(1) 1990.
@@ -48,14 +42,11 @@ extern const float __t_sqrt[1024];
    generated guesses (which mostly runs on the integer unit, while the
    Newton-Raphson is running on the FPU).  */
 
-float
-__slow_ieee754_sqrtf (float x)
-{
-  const float inf = a_inf.value;
+  extern const float __t_sqrt[1024];
 
   if (x > 0)
     {
-      if (x != inf)
+      if (x != INFINITY)
 	{
 	  /* Variables named starting with 's' exist in the
 	     argument-reduced space, so that 2 > sx >= 0.5,
@@ -94,7 +85,7 @@ __slow_ieee754_sqrtf (float x)
 	  sy2 = sy + sy;
 	  sg = __builtin_fmaf (sy, sd, sg);	/* 16-bit approximation to
 						   sqrt(sx). */
-	  e = -__builtin_fmaf (sy, sg, -almost_half);
+	  e = -__builtin_fmaf (sy, sg, -0x1.0000020365653p-1);
 	  SET_FLOAT_WORD (fsg, fsgi);
 	  sd = -__builtin_fmaf (sg, sg, -sx);
 	  sy = __builtin_fmaf (e, sy2, sy);
@@ -106,7 +97,7 @@ __slow_ieee754_sqrtf (float x)
 						   rounded incorrectly.  */
 	  sy2 = sy + sy;
 	  g = sg * fsg;
-	  e = -__builtin_fmaf (sy, sg, -almost_half);
+	  e = -__builtin_fmaf (sy, sg, -0x1.0000020365653p-1);
 	  d = -__builtin_fmaf (g, sg, -shx);
 	  sy = __builtin_fmaf (e, sy2, sy);
 	  fesetenv_register (fe);
@@ -115,38 +106,23 @@ __slow_ieee754_sqrtf (float x)
 	  /* For denormalised numbers, we normalise, calculate the
 	     square root, and return an adjusted result.  */
 	  fesetenv_register (fe);
-	  return __slow_ieee754_sqrtf (x * two48) * twom24;
+	  return __ieee754_sqrtf (x * 0x1p+48) * 0x1p-24;
 	}
     }
   else if (x < 0)
     {
       /* For some reason, some PowerPC32 processors don't implement
 	 FE_INVALID_SQRT.  */
-#ifdef FE_INVALID_SQRT
+# ifdef FE_INVALID_SQRT
       feraiseexcept (FE_INVALID_SQRT);
 
       fenv_union_t u = { .fenv = fegetenv_register () };
       if ((u.l & FE_INVALID) == 0)
-#endif
+# endif
 	feraiseexcept (FE_INVALID);
-      x = a_nan.value;
+      x = NAN;
     }
   return f_washf (x);
-}
-#endif /* _ARCH_PPCSQ  */
-
-#undef __ieee754_sqrtf
-float
-__ieee754_sqrtf (float x)
-{
-  float z;
-
-#ifdef _ARCH_PPCSQ
-  asm ("fsqrts	%0,%1\n" :"=f" (z):"f" (x));
-#else
-  z = __slow_ieee754_sqrtf (x);
-#endif
-
-  return z;
+#endif /* USE_SQRTF_BUILTIN  */
 }
 libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/powerpc/fpu/math-use-builtins-sqrt.h b/sysdeps/powerpc/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..653309a7e7
--- /dev/null
+++ b/sysdeps/powerpc/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,9 @@
+#ifdef _ARCH_PPCSQ
+# define USE_SQRT_BUILTIN 1
+# define USE_SQRTF_BUILTIN 1
+#else
+# define USE_SQRT_BUILTIN 0
+# define USE_SQRTF_BUILTIN 0
+#endif
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 05/13] x86_64: Use builtin sqrt{f,l}
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 04/13] powerpc: Use sqrt{f} builtin Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 06/13] i386: Use builtin sqrtl Adhemerval Zanella
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Checked on x86_64-linux-gnu.
---
 sysdeps/x86_64/fpu/e_sqrt.c                 | 32 ---------------------
 sysdeps/x86_64/fpu/e_sqrtf.c                | 32 ---------------------
 sysdeps/x86_64/fpu/e_sqrtl.c                | 28 +++++++++++++++++-
 sysdeps/x86_64/fpu/math-use-builtins-sqrt.h |  4 +++
 4 files changed, 31 insertions(+), 65 deletions(-)
 delete mode 100644 sysdeps/x86_64/fpu/e_sqrt.c
 delete mode 100644 sysdeps/x86_64/fpu/e_sqrtf.c
 create mode 100644 sysdeps/x86_64/fpu/math-use-builtins-sqrt.h

diff --git a/sysdeps/x86_64/fpu/e_sqrt.c b/sysdeps/x86_64/fpu/e_sqrt.c
deleted file mode 100644
index c1708f9b65..0000000000
--- a/sysdeps/x86_64/fpu/e_sqrt.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Square root of floating point number.
-   Copyright (C) 2002-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-#undef __ieee754_sqrt
-double
-__ieee754_sqrt (double x)
-{
-  double res;
-
-  asm ("sqrtsd %1, %0" : "=x" (res) : "xm" (x));
-
-  return res;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/x86_64/fpu/e_sqrtf.c b/sysdeps/x86_64/fpu/e_sqrtf.c
deleted file mode 100644
index 6155c7be24..0000000000
--- a/sysdeps/x86_64/fpu/e_sqrtf.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Square root of floating point number.
-   Copyright (C) 2002-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-#undef __ieee754_sqrtf
-float
-__ieee754_sqrtf (float x)
-{
-  float res;
-
-  asm ("sqrtss %1, %0" : "=x" (res) : "xm" (x));
-
-  return res;
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/x86_64/fpu/e_sqrtl.c b/sysdeps/x86_64/fpu/e_sqrtl.c
index 90e4e164e5..7ea6f52058 100644
--- a/sysdeps/x86_64/fpu/e_sqrtl.c
+++ b/sysdeps/x86_64/fpu/e_sqrtl.c
@@ -1 +1,27 @@
-#include "sysdeps/i386/fpu/e_sqrtl.c"
+/* Square root function.  x86_64 long double version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <libm-alias-finite.h>
+
+long double
+__ieee754_sqrtl (long double x)
+{
+  return __builtin_sqrtl (x);
+}
+libm_alias_finite (__ieee754_sqrtl, __sqrtl)
diff --git a/sysdeps/x86_64/fpu/math-use-builtins-sqrt.h b/sysdeps/x86_64/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e94c915ba6
--- /dev/null
+++ b/sysdeps/x86_64/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 06/13] i386: Use builtin sqrtl
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 05/13] x86_64: Use builtin sqrt{f,l} Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 07/13] alpha: Use builtin sqrt{f} Adhemerval Zanella
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Checked on i686-linux-gnu.
---
 sysdeps/i386/fpu/e_sqrtl.c            | 21 ---------------------
 sysdeps/{x86_64 => x86}/fpu/e_sqrtl.c |  0
 2 files changed, 21 deletions(-)
 delete mode 100644 sysdeps/i386/fpu/e_sqrtl.c
 rename sysdeps/{x86_64 => x86}/fpu/e_sqrtl.c (100%)

diff --git a/sysdeps/i386/fpu/e_sqrtl.c b/sysdeps/i386/fpu/e_sqrtl.c
deleted file mode 100644
index 8f284dd75c..0000000000
--- a/sysdeps/i386/fpu/e_sqrtl.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
- * Public domain.
- *
- * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
- */
-
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-#undef __ieee754_sqrtl
-long double
-__ieee754_sqrtl (long double x)
-{
-  long double res;
-
-  asm ("fsqrt" : "=t" (res) : "0" (x));
-
-  return res;
-}
-libm_alias_finite (__ieee754_sqrtl, __sqrtl)
diff --git a/sysdeps/x86_64/fpu/e_sqrtl.c b/sysdeps/x86/fpu/e_sqrtl.c
similarity index 100%
rename from sysdeps/x86_64/fpu/e_sqrtl.c
rename to sysdeps/x86/fpu/e_sqrtl.c
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 07/13] alpha: Use builtin sqrt{f}
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 06/13] i386: Use builtin sqrtl Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 08/13] mips: Use sqrt{f} builtin Adhemerval Zanella
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

The generic implementation is simplified by removing the
'optimization' for !_IEEE_FP_INEXACT (which does not handle
inexact neither some values).

Checked on alpha-linux-gnu.
---
 sysdeps/alpha/alphaev6/fpu/e_sqrt.S        |  53 -------
 sysdeps/alpha/alphaev6/fpu/e_sqrtf.S       |  53 -------
 sysdeps/alpha/fpu/e_sqrt.c                 | 164 +--------------------
 sysdeps/alpha/fpu/e_sqrtf.c                |   9 +-
 sysdeps/alpha/fpu/math-use-builtins-sqrt.h |   9 ++
 5 files changed, 13 insertions(+), 275 deletions(-)
 delete mode 100644 sysdeps/alpha/alphaev6/fpu/e_sqrt.S
 delete mode 100644 sysdeps/alpha/alphaev6/fpu/e_sqrtf.S
 create mode 100644 sysdeps/alpha/fpu/math-use-builtins-sqrt.h

diff --git a/sysdeps/alpha/alphaev6/fpu/e_sqrt.S b/sysdeps/alpha/alphaev6/fpu/e_sqrt.S
deleted file mode 100644
index 33596e2ed3..0000000000
--- a/sysdeps/alpha/alphaev6/fpu/e_sqrt.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <shlib-compat.h>
-
-	.arch ev6
-	.set noreorder
-	.set noat
-
-ENTRY(__ieee754_sqrt)
-#ifdef PROF
-	ldgp    gp, 0(pv)
-	lda     AT, _mcount
-	jsr     AT, (AT), _mcount
-	.prologue 1
-#else
-	.prologue 0
-#endif
-
-	.align 4
-#ifdef _IEEE_FP_INEXACT
-	sqrtt/suid $f16, $f0
-#else
-	sqrtt/sud $f16, $f0
-#endif
-	ret
-	nop
-	nop
-
-END(__ieee754_sqrt)
-
-#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
-strong_alias(__ieee754_sqrt, __sqrt_dummy)
-compat_symbol(libm, __sqrt_dummy, __sqrt_finite, GLIBC_2_15)
-#endif
-#if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
-compat_symbol(libm, __ieee754_sqrt, __sqrt_finite, GLIBC_2_18)
-#endif
diff --git a/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S b/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S
deleted file mode 100644
index 36e04cce38..0000000000
--- a/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <shlib-compat.h>
-
-	.arch ev6
-	.set noreorder
-	.set noat
-
-ENTRY(__ieee754_sqrtf)
-#ifdef PROF
-	ldgp    gp, 0(pv)
-	lda     AT, _mcount
-	jsr     AT, (AT), _mcount
-	.prologue 1
-#else
-	.prologue 0
-#endif
-
-	.align 4
-#ifdef _IEEE_FP_INEXACT
-	sqrts/suid $f16, $f0
-#else
-	sqrts/sud $f16, $f0
-#endif
-	ret
-	nop
-	nop
-
-END(__ieee754_sqrtf)
-
-#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
-strong_alias(__ieee754_sqrtf, __sqrtf_dummy)
-compat_symbol(libm, __sqrtf_dummy, __sqrtf_finite, GLIBC_2_15)
-#endif
-#if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
-compat_symbol(libm, __ieee754_sqrtf, __sqrtf_finite, GLIBC_2_18)
-#endif
diff --git a/sysdeps/alpha/fpu/e_sqrt.c b/sysdeps/alpha/fpu/e_sqrt.c
index 4cf2ad693a..c75ed07bd6 100644
--- a/sysdeps/alpha/fpu/e_sqrt.c
+++ b/sysdeps/alpha/fpu/e_sqrt.c
@@ -16,171 +16,11 @@
    License along with the GNU C Library.  If not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#include <math_private.h>
 #include <shlib-compat.h>
 
-#if !defined(_IEEE_FP_INEXACT)
-
-/*
- * This version is much faster than generic sqrt implementation, but
- * it doesn't handle the inexact flag.  It doesn't handle exceptional
- * values either, but will defer to the full ieee754_sqrt routine which
- * can.
- */
-
-/* Careful with rearranging this without consulting the assembly below.  */
-const static struct sqrt_data_struct {
-	unsigned long dn, up, half, almost_three_half;
-	unsigned long one_and_a_half, two_to_minus_30, one, nan;
-	const int T2[64];
-} sqrt_data __attribute__((used)) = {
-	0x3fefffffffffffff,	/* __dn = nextafter(1,-Inf) */
-	0x3ff0000000000001,	/* __up = nextafter(1,+Inf) */
-	0x3fe0000000000000,	/* half */
-	0x3ff7ffffffc00000,	/* almost_three_half = 1.5-2^-30 */
-	0x3ff8000000000000,	/* one_and_a_half */
-	0x3e10000000000000,	/* two_to_minus_30 */
-	0x3ff0000000000000,	/* one */
-	0xffffffffffffffff,	/* nan */
-
-	{ 0x1500, 0x2ef8, 0x4d67, 0x6b02, 0x87be, 0xa395, 0xbe7a, 0xd866,
-	0xf14a, 0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f,
-	0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d,
-	0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0,
-	0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989,
-	0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd,
-	0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e,
-	0x1527f,0x1334a,0x11051,0xe951, 0xbe01, 0x8e0d, 0x5924, 0x1edd }
-};
-
-asm ("\
-  /* Define offsets into the structure defined in C above.  */		\n\
-	$DN = 0*8							\n\
-	$UP = 1*8							\n\
-	$HALF = 2*8							\n\
-	$ALMOST_THREE_HALF = 3*8					\n\
-	$NAN = 7*8							\n\
-	$T2 = 8*8							\n\
-									\n\
-  /* Stack variables.  */						\n\
-	$K = 0								\n\
-	$Y = 8								\n\
-									\n\
-	.text								\n\
-	.align	5							\n\
-	.globl	__ieee754_sqrt						\n\
-	.ent	__ieee754_sqrt						\n\
-__ieee754_sqrt:								\n\
-	ldgp	$29, 0($27)						\n\
-	subq	$sp, 16, $sp						\n\
-	.frame	$sp, 16, $26, 0\n"
-#ifdef PROF
-"	lda	$28, _mcount						\n\
-	jsr	$28, ($28), _mcount\n"
-#endif
-"	.prologue 1							\n\
-									\n\
-	.align 4							\n\
-	stt	$f16, $K($sp)		# e0    :			\n\
-	mult	$f31, $f31, $f31	# .. fm :			\n\
-	lda	$4, sqrt_data		# e0    :			\n\
-	fblt	$f16, $fixup		# .. fa :			\n\
-									\n\
-	ldah	$2, 0x5fe8		# e0    :			\n\
-	ldq	$3, $K($sp)		# .. e1 :			\n\
-	ldt	$f12, $HALF($4)		# e0    :			\n\
-	ldt	$f18, $ALMOST_THREE_HALF($4)	# .. e1 :		\n\
-									\n\
-	sll	$3, 52, $5		# e0    :			\n\
-	lda	$6, 0x7fd		# .. e1 :			\n\
-	fnop				# .. fa :			\n\
-	fnop				# .. fm :			\n\
-									\n\
-	subq	$5, 1, $5		# e1    :			\n\
-	srl	$3, 33, $1		# .. e0 :			\n\
-	cmpule	$5, $6, $5		# e0    :			\n\
-	beq	$5, $fixup		# .. e1 :			\n\
-									\n\
-	mult	$f16, $f12, $f11	# fm    : $f11 = x * 0.5	\n\
-	subl	$2, $1, $2		# .. e0 :			\n\
-	addt	$f12, $f12, $f17	# .. fa : $f17 = 1.0		\n\
-	srl	$2, 12, $1		# e0    :			\n\
-									\n\
-	and	$1, 0xfc, $1		# e0    :			\n\
-	addq	$1, $4, $1		# e1    :			\n\
-	ldl	$1, $T2($1)		# e0    :			\n\
-	addt	$f12, $f17, $f15	# .. fa : $f15 = 1.5		\n\
-									\n\
-	subl	$2, $1, $2		# e0    :			\n\
-	ldt	$f14, $DN($4)		# .. e1 :			\n\
-	sll	$2, 32, $2		# e0    :			\n\
-	stq	$2, $Y($sp)		# e0    :			\n\
-									\n\
-	ldt	$f13, $Y($sp)		# e0    :			\n\
-	mult/su	$f11, $f13, $f10	# fm   2: $f10 = (x * 0.5) * y	\n\
-	mult	$f10, $f13, $f10	# fm   4: $f10 = ((x*0.5)*y)*y	\n\
-	subt	$f15, $f10, $f1		# fa   4: $f1 = (1.5-0.5*x*y*y)	\n\
-									\n\
-	mult	$f13, $f1, $f13         # fm   4: yp = y*(1.5-0.5*x*y^2)\n\
-	mult/su	$f11, $f13, $f1		# fm   4: $f11 = x * 0.5 * yp	\n\
-	mult	$f1, $f13, $f11		# fm   4: $f11 = (x*0.5*yp)*yp	\n\
-	subt	$f18, $f11, $f1		# fa   4: $f1=(1.5-2^-30)-x/2*yp^2\n\
-									\n\
-	mult	$f13, $f1, $f13		# fm   4: ypp = $f13 = yp*$f1	\n\
-	subt	$f15, $f12, $f1		# .. fa : $f1 = (1.5 - 0.5)	\n\
-	ldt	$f15, $UP($4)		# .. e0 :			\n\
-	mult/su	$f16, $f13, $f10	# fm   4: z = $f10 = x * ypp	\n\
-									\n\
-	mult	$f10, $f13, $f11	# fm   4: $f11 = z*ypp		\n\
-	mult	$f10, $f12, $f12	# fm    : $f12 = z*0.5		\n\
-	subt	$f1, $f11, $f1		# fa   4: $f1 = 1 - z*ypp	\n\
-	mult	$f12, $f1, $f12		# fm   4: $f12 = z/2*(1 - z*ypp)\n\
-									\n\
-	addt	$f10, $f12, $f0		# fa   4: zp=res= z+z/2*(1-z*ypp)\n\
-	mult/c	$f0, $f14, $f12		# fm   4: zmi = zp * DN		\n\
-	mult/c	$f0, $f15, $f11		# fm    : zpl = zp * UP		\n\
-	mult/c	$f0, $f12, $f1		# fm    : $f1 = zp * zmi	\n\
-									\n\
-	mult/c	$f0, $f11, $f15		# fm    : $f15 = zp * zpl	\n\
-	subt/su	$f1, $f16, $f13		# .. fa : y1 = zp*zmi - x	\n\
-	subt/su	$f15, $f16, $f14	# fa   4: y2 = zp*zpl - x	\n\
-	fcmovge	$f13, $f12, $f0		# fa   3: res = (y1>=0)?zmi:res	\n\
-									\n\
-	fcmovlt	$f14, $f11, $f0		# fa   4: res = (y2<0)?zpl:res	\n\
-	addq	$sp, 16, $sp		# .. e0 :			\n\
-	ret				# .. e1 :			\n\
-									\n\
-	.align 4							\n\
-$fixup:									\n\
-	addq	$sp, 16, $sp						\n\
-	br	__full_ieee754_sqrt	!samegp				\n\
-									\n\
-	.end	__ieee754_sqrt");
-
-#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
-asm (".global  __sqrt_dummy; __sqrt_dummy = __ieee754_sqrt");
-#else
-asm (".global  __sqrt_finite; __sqrt_finite = __ieee754_sqrt");
-#endif
-
-static double __full_ieee754_sqrt(double) __attribute_used__;
-#define __ieee754_sqrt __full_ieee754_sqrt
-
-#elif SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
-
-strong_alias (__ieee754_sqrt, __sqrt_dummy)
-#define __ieee754_sqrt __ieee754_sqrt
-
-#endif /* _IEEE_FP_INEXACT */
-
 #include <sysdeps/ieee754/dbl-64/e_sqrt.c>
-#undef __ieee754_sqrt
 
-/* Work around forgotten symbol in alphaev6 build.  */
-#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
-compat_symbol (libm, __sqrt_dummy, __sqrt_finite, GLIBC_2_15);
-#endif
 #if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
-compat_symbol (libm, __ieee754_sqrt, __sqrt_finite, GLIBC_2_18);
+strong_alias (__ieee754_sqrt, __sqrt_finite_2_18)
+compat_symbol (libm, __sqrt_finite_2_18, __sqrt_finite, GLIBC_2_18);
 #endif
diff --git a/sysdeps/alpha/fpu/e_sqrtf.c b/sysdeps/alpha/fpu/e_sqrtf.c
index eb3f968576..38c41db537 100644
--- a/sysdeps/alpha/fpu/e_sqrtf.c
+++ b/sysdeps/alpha/fpu/e_sqrtf.c
@@ -1,13 +1,8 @@
 #include <shlib-compat.h>
 
-#define __ieee754_sqrtf __ieee754_sqrtf
 #include <sysdeps/ieee754/flt-32/e_sqrtf.c>
 
-/* Work around forgotten symbol in alphaev6 build.  */
-#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
-strong_alias(__ieee754_sqrtf, __sqrtf_dummy)
-compat_symbol (libm, __sqrtf_dummy, __sqrtf_finite, GLIBC_2_15);
-#endif
 #if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
-compat_symbol (libm, __ieee754_sqrtf, __sqrtf_finite, GLIBC_2_18);
+strong_alias (__ieee754_sqrtf, __sqrtf_finite_2_18)
+compat_symbol (libm, __sqrtf_finite_2_18, __sqrtf_finite, GLIBC_2_18);
 #endif
diff --git a/sysdeps/alpha/fpu/math-use-builtins-sqrt.h b/sysdeps/alpha/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..550b097ed6
--- /dev/null
+++ b/sysdeps/alpha/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,9 @@
+#ifdef __alpha_ev6__
+# define USE_SQRT_BUILTIN 1
+# define USE_SQRTF_BUILTIN 1
+#else
+# define USE_SQRT_BUILTIN 0
+# define USE_SQRTF_BUILTIN 0
+#endif
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 08/13] mips: Use sqrt{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 07/13] alpha: Use builtin sqrt{f} Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 09/13] sparc: " Adhemerval Zanella
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Checked with a build against mips-linux-gnu and mips64-linux-gnu
and comparing the resulting binaries.
---
 sysdeps/mips/fpu/e_sqrt.c                 | 38 -----------------------
 sysdeps/mips/fpu/e_sqrtf.c                | 38 -----------------------
 sysdeps/mips/fpu/math-use-builtins-sqrt.h |  6 ++++
 sysdeps/mips/mips32/fpu/e_sqrt.c          |  1 -
 sysdeps/mips/mips32/fpu/e_sqrtf.c         |  1 -
 sysdeps/mips/mips64/n32/fpu/e_sqrt.c      |  1 -
 sysdeps/mips/mips64/n32/fpu/e_sqrtf.c     |  1 -
 sysdeps/mips/mips64/n64/fpu/e_sqrt.c      |  1 -
 sysdeps/mips/mips64/n64/fpu/e_sqrtf.c     |  1 -
 9 files changed, 6 insertions(+), 82 deletions(-)
 delete mode 100644 sysdeps/mips/fpu/e_sqrt.c
 delete mode 100644 sysdeps/mips/fpu/e_sqrtf.c
 create mode 100644 sysdeps/mips/fpu/math-use-builtins-sqrt.h
 delete mode 100644 sysdeps/mips/mips32/fpu/e_sqrt.c
 delete mode 100644 sysdeps/mips/mips32/fpu/e_sqrtf.c
 delete mode 100644 sysdeps/mips/mips64/n32/fpu/e_sqrt.c
 delete mode 100644 sysdeps/mips/mips64/n32/fpu/e_sqrtf.c
 delete mode 100644 sysdeps/mips/mips64/n64/fpu/e_sqrt.c
 delete mode 100644 sysdeps/mips/mips64/n64/fpu/e_sqrtf.c

diff --git a/sysdeps/mips/fpu/e_sqrt.c b/sysdeps/mips/fpu/e_sqrt.c
deleted file mode 100644
index 47488e993c..0000000000
--- a/sysdeps/mips/fpu/e_sqrt.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-
-#include <sgidefs.h>
-#include <libm-alias-finite.h>
-
-#if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
-
-double __attribute__ ((nomips16))
-__ieee754_sqrt (double x)
-{
-  double z;
-  __asm__ ("sqrt.d %0,%1" : "=f" (z) : "f" (x));
-  return z;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
-
-#else
-
-#include <sysdeps/ieee754/dbl-64/e_sqrt.c>
-
-#endif
diff --git a/sysdeps/mips/fpu/e_sqrtf.c b/sysdeps/mips/fpu/e_sqrtf.c
deleted file mode 100644
index dc33788bf3..0000000000
--- a/sysdeps/mips/fpu/e_sqrtf.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-
-#include <sgidefs.h>
-#include <libm-alias-finite.h>
-
-#if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
-
-float __attribute__ ((nomips16))
-__ieee754_sqrtf (float x)
-{
-  float z;
-  __asm__ ("sqrt.s %0,%1" : "=f" (z) : "f" (x));
-  return z;
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
-
-#else
-
-#include <sysdeps/ieee754/flt-32/e_sqrtf.c>
-
-#endif
diff --git a/sysdeps/mips/fpu/math-use-builtins-sqrt.h b/sysdeps/mips/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..37f49ebc9f
--- /dev/null
+++ b/sysdeps/mips/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,6 @@
+#include <sgidefs.h>
+
+#define USE_SQRT_BUILTIN (_MIPS_ISA >= _MIPS_ISA_MIPS2)
+#define USE_SQRTF_BUILTIN (_MIPS_ISA >= _MIPS_ISA_MIPS2)
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
diff --git a/sysdeps/mips/mips32/fpu/e_sqrt.c b/sysdeps/mips/mips32/fpu/e_sqrt.c
deleted file mode 100644
index 81f4e77697..0000000000
--- a/sysdeps/mips/mips32/fpu/e_sqrt.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/mips/fpu/e_sqrt.c>
diff --git a/sysdeps/mips/mips32/fpu/e_sqrtf.c b/sysdeps/mips/mips32/fpu/e_sqrtf.c
deleted file mode 100644
index fb0700d45c..0000000000
--- a/sysdeps/mips/mips32/fpu/e_sqrtf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/mips/fpu/e_sqrtf.c>
diff --git a/sysdeps/mips/mips64/n32/fpu/e_sqrt.c b/sysdeps/mips/mips64/n32/fpu/e_sqrt.c
deleted file mode 100644
index 81f4e77697..0000000000
--- a/sysdeps/mips/mips64/n32/fpu/e_sqrt.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/mips/fpu/e_sqrt.c>
diff --git a/sysdeps/mips/mips64/n32/fpu/e_sqrtf.c b/sysdeps/mips/mips64/n32/fpu/e_sqrtf.c
deleted file mode 100644
index fb0700d45c..0000000000
--- a/sysdeps/mips/mips64/n32/fpu/e_sqrtf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/mips/fpu/e_sqrtf.c>
diff --git a/sysdeps/mips/mips64/n64/fpu/e_sqrt.c b/sysdeps/mips/mips64/n64/fpu/e_sqrt.c
deleted file mode 100644
index 81f4e77697..0000000000
--- a/sysdeps/mips/mips64/n64/fpu/e_sqrt.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/mips/fpu/e_sqrt.c>
diff --git a/sysdeps/mips/mips64/n64/fpu/e_sqrtf.c b/sysdeps/mips/mips64/n64/fpu/e_sqrtf.c
deleted file mode 100644
index fb0700d45c..0000000000
--- a/sysdeps/mips/mips64/n64/fpu/e_sqrtf.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/mips/fpu/e_sqrtf.c>
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 09/13] sparc: Use sqrt{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 08/13] mips: Use sqrt{f} builtin Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:32 ` [PATCH 10/13] s390: " Adhemerval Zanella
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

It also enabled to use fsqrtd on sparc64.

Checked on sparcv9-linux-gnu and sparc64-linux-gnu.
---
 sysdeps/sparc/fpu/math-use-builtins-sqrt.h |  4 +++
 sysdeps/sparc/sparc32/e_sqrt.c             | 34 ----------------------
 2 files changed, 4 insertions(+), 34 deletions(-)
 create mode 100644 sysdeps/sparc/fpu/math-use-builtins-sqrt.h
 delete mode 100644 sysdeps/sparc/sparc32/e_sqrt.c

diff --git a/sysdeps/sparc/fpu/math-use-builtins-sqrt.h b/sysdeps/sparc/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e94c915ba6
--- /dev/null
+++ b/sysdeps/sparc/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
diff --git a/sysdeps/sparc/sparc32/e_sqrt.c b/sysdeps/sparc/sparc32/e_sqrt.c
deleted file mode 100644
index e8a42c4d7b..0000000000
--- a/sysdeps/sparc/sparc32/e_sqrt.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <math.h>
-#include <libm-alias-finite.h>
-
-#ifndef	__GNUC__
-  #error This file uses GNU C extensions; you must compile with GCC.
-#endif
-
-/* Return the square root of X.  */
-double
-__ieee754_sqrt (double x)
-{
-  register double result;
-  asm ("fsqrtd %1, %0" : "=f" (result) : "f" (x));
-  return result;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 10/13] s390: Use sqrt{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 09/13] sparc: " Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-10 15:39   ` Stefan Liebler
  2020-06-09 21:32 ` [PATCH 11/13] riscv: " Adhemerval Zanella
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Checked on s390x-linux-gnu.
---
 sysdeps/s390/fpu/e_sqrt.c                 | 30 -----------------------
 sysdeps/s390/fpu/e_sqrtf.c                | 30 -----------------------
 sysdeps/s390/fpu/math-use-builtins-sqrt.h |  4 +++
 3 files changed, 4 insertions(+), 60 deletions(-)
 delete mode 100644 sysdeps/s390/fpu/e_sqrt.c
 delete mode 100644 sysdeps/s390/fpu/e_sqrtf.c
 create mode 100644 sysdeps/s390/fpu/math-use-builtins-sqrt.h

diff --git a/sysdeps/s390/fpu/e_sqrt.c b/sysdeps/s390/fpu/e_sqrt.c
deleted file mode 100644
index 484c6aae95..0000000000
--- a/sysdeps/s390/fpu/e_sqrt.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
-   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-double
-__ieee754_sqrt (double x)
-{
-  double res;
-
-  __asm__ ( "sqdbr %0,%1" : "=f" (res) : "f" (x) );
-  return res;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/s390/fpu/e_sqrtf.c b/sysdeps/s390/fpu/e_sqrtf.c
deleted file mode 100644
index bce49c90f1..0000000000
--- a/sysdeps/s390/fpu/e_sqrtf.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
-   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math_private.h>
-#include <libm-alias-finite.h>
-
-float
-__ieee754_sqrtf (float x)
-{
-  float res;
-
-  __asm__ ( "sqebr %0,%1" : "=f" (res) : "f" (x) );
-  return res;
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/s390/fpu/math-use-builtins-sqrt.h b/sysdeps/s390/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e94c915ba6
--- /dev/null
+++ b/sysdeps/s390/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 11/13] riscv: Use sqrt{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (8 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 10/13] s390: " Adhemerval Zanella
@ 2020-06-09 21:32 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:33 ` [PATCH 12/13] arm: " Adhemerval Zanella
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:32 UTC (permalink / raw)
  To: libc-alpha

Checked with a build for riscv64-linux-gnu-rv64imac-lp64 (no
builtin support), riscv64-linux-gnu-rv64imafdc-lp64, and
riscv64-linux-gnu-rv64imafdc-lp64d.
---
 sysdeps/riscv/rvd/e_sqrt.c                 | 28 ----------------------
 sysdeps/riscv/rvd/math-use-builtins-sqrt.h |  4 ++++
 sysdeps/riscv/rvf/e_sqrtf.c                | 28 ----------------------
 3 files changed, 4 insertions(+), 56 deletions(-)
 delete mode 100644 sysdeps/riscv/rvd/e_sqrt.c
 create mode 100644 sysdeps/riscv/rvd/math-use-builtins-sqrt.h
 delete mode 100644 sysdeps/riscv/rvf/e_sqrtf.c

diff --git a/sysdeps/riscv/rvd/e_sqrt.c b/sysdeps/riscv/rvd/e_sqrt.c
deleted file mode 100644
index 7defcb5785..0000000000
--- a/sysdeps/riscv/rvd/e_sqrt.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Double precision floating point square root.  RISC-V version.
-   Copyright (C) 2017-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <libm-alias-finite.h>
-
-double
-__ieee754_sqrt (double x)
-{
-  asm ("fsqrt.d %0, %1" : "=f" (x) : "f" (x));
-  return x;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/riscv/rvd/math-use-builtins-sqrt.h b/sysdeps/riscv/rvd/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e94c915ba6
--- /dev/null
+++ b/sysdeps/riscv/rvd/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
diff --git a/sysdeps/riscv/rvf/e_sqrtf.c b/sysdeps/riscv/rvf/e_sqrtf.c
deleted file mode 100644
index 04835e3e53..0000000000
--- a/sysdeps/riscv/rvf/e_sqrtf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Single precision floating point square root.  RISC-V version.
-   Copyright (C) 2017-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <math.h>
-#include <libm-alias-finite.h>
-
-float
-__ieee754_sqrtf (float x)
-{
-  asm ("fsqrt.s %0, %1" : "=f" (x) : "f" (x));
-  return x;
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 12/13] arm: Use sqrt{f} builtin
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (9 preceding siblings ...)
  2020-06-09 21:32 ` [PATCH 11/13] riscv: " Adhemerval Zanella
@ 2020-06-09 21:33 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-09 21:33 ` [PATCH 13/13] m68k: Use sqrt{f} builtin for coldfire Adhemerval Zanella
  2020-06-16 10:13 ` [PATCH 01/13] math: Decompose math-use-builtins.h Stefan Liebler
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:33 UTC (permalink / raw)
  To: libc-alpha

Checked on arm-linux-gnueabi and armv7-linux-gnueabihf
---
 sysdeps/arm/e_sqrt.c                 | 46 ----------------------------
 sysdeps/arm/e_sqrtf.c                | 46 ----------------------------
 sysdeps/arm/math-use-builtins-sqrt.h |  9 ++++++
 3 files changed, 9 insertions(+), 92 deletions(-)
 delete mode 100644 sysdeps/arm/e_sqrt.c
 delete mode 100644 sysdeps/arm/e_sqrtf.c
 create mode 100644 sysdeps/arm/math-use-builtins-sqrt.h

diff --git a/sysdeps/arm/e_sqrt.c b/sysdeps/arm/e_sqrt.c
deleted file mode 100644
index d264c4263b..0000000000
--- a/sysdeps/arm/e_sqrt.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Compute square root for double.  ARM version.
-   Copyright (C) 2016-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifdef __SOFTFP__
-
-/* Use architecture-indendent sqrt implementation.  */
-# include <sysdeps/ieee754/dbl-64/e_sqrt.c>
-
-#else
-
-/* Use VFP square root instruction.  */
-# include <math.h>
-# include <sysdep.h>
-# include <libm-alias-finite.h>
-
-double
-__ieee754_sqrt (double x)
-{
-  double ret;
-# if __ARM_ARCH >= 6
-  asm ("vsqrt.f64 %P0, %P1" : "=w" (ret) : "w" (x));
-# else
-  /* As in GCC, for VFP9 Erratum 760019 avoid overwriting the
-     input.  */
-  asm ("vsqrt.f64 %P0, %P1" : "=&w" (ret) : "w" (x));
-# endif
-  return ret;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
-
-#endif
diff --git a/sysdeps/arm/e_sqrtf.c b/sysdeps/arm/e_sqrtf.c
deleted file mode 100644
index c3f31119a3..0000000000
--- a/sysdeps/arm/e_sqrtf.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Compute square root for float.  ARM version.
-   Copyright (C) 2016-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifdef __SOFTFP__
-
-/* Use architecture-indendent sqrtf implementation.  */
-# include <sysdeps/ieee754/flt-32/e_sqrtf.c>
-
-#else
-
-/* Use VFP square root instruction.  */
-# include <math.h>
-# include <sysdep.h>
-# include <libm-alias-finite.h>
-
-float
-__ieee754_sqrtf (float x)
-{
-  float ret;
-# if __ARM_ARCH >= 6
-  asm ("vsqrt.f32 %0, %1" : "=t" (ret) : "t" (x));
-# else
-  /* As in GCC, for VFP9 Erratum 760019 avoid overwriting the
-     input.  */
-  asm ("vsqrt.f32 %0, %1" : "=&t" (ret) : "t" (x));
-# endif
-  return ret;
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
-
-#endif
diff --git a/sysdeps/arm/math-use-builtins-sqrt.h b/sysdeps/arm/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e765e7c49d
--- /dev/null
+++ b/sysdeps/arm/math-use-builtins-sqrt.h
@@ -0,0 +1,9 @@
+#ifdef __SOFTFP__
+# define USE_SQRT_BUILTIN 0
+# define USE_SQRTF_BUILTIN 0
+#else
+# define USE_SQRT_BUILTIN 1
+# define USE_SQRTF_BUILTIN 1
+#endif
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* [PATCH 13/13] m68k: Use sqrt{f} builtin for coldfire
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (10 preceding siblings ...)
  2020-06-09 21:33 ` [PATCH 12/13] arm: " Adhemerval Zanella
@ 2020-06-09 21:33 ` Adhemerval Zanella
  2020-06-19 19:17   ` Adhemerval Zanella
  2020-06-16 10:13 ` [PATCH 01/13] math: Decompose math-use-builtins.h Stefan Liebler
  12 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-09 21:33 UTC (permalink / raw)
  To: libc-alpha

Checked with a build for m68k-linux-gnu-coldfire.
---
 sysdeps/m68k/coldfire/fpu/e_sqrt.c            | 26 ------------------
 sysdeps/m68k/coldfire/fpu/e_sqrtf.c           | 27 -------------------
 .../coldfire/fpu/math-use-builtins-sqrt.h     |  4 +++
 3 files changed, 4 insertions(+), 53 deletions(-)
 delete mode 100644 sysdeps/m68k/coldfire/fpu/e_sqrt.c
 delete mode 100644 sysdeps/m68k/coldfire/fpu/e_sqrtf.c
 create mode 100644 sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h

diff --git a/sysdeps/m68k/coldfire/fpu/e_sqrt.c b/sysdeps/m68k/coldfire/fpu/e_sqrt.c
deleted file mode 100644
index c67630d1b8..0000000000
--- a/sysdeps/m68k/coldfire/fpu/e_sqrt.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <libm-alias-finite.h>
-
-double
-__ieee754_sqrt (double x)
-{
-  asm ("fdsqrt.d %1,%0" : "=f" (x) : "fm" (x));
-  return x;
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/m68k/coldfire/fpu/e_sqrtf.c b/sysdeps/m68k/coldfire/fpu/e_sqrtf.c
deleted file mode 100644
index c2e4928957..0000000000
--- a/sysdeps/m68k/coldfire/fpu/e_sqrtf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <libm-alias-finite.h>
-
-float
-__ieee754_sqrtf (float x)
-{
-  double result;
-  asm ("fssqrt.s %1,%0" : "=f" (result) : "dm" (x));
-  return result;
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h b/sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h
new file mode 100644
index 0000000000..e94c915ba6
--- /dev/null
+++ b/sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h
@@ -0,0 +1,4 @@
+#define USE_SQRT_BUILTIN 1
+#define USE_SQRTF_BUILTIN 1
+#define USE_SQRTL_BUILTIN 0
+#define USE_SQRTF128_BUILTIN 0
-- 
2.25.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f}
  2020-06-09 21:32 ` [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f} Adhemerval Zanella
@ 2020-06-10 10:15   ` Szabolcs Nagy
  0 siblings, 0 replies; 29+ messages in thread
From: Szabolcs Nagy @ 2020-06-10 10:15 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

The 06/09/2020 18:32, Adhemerval Zanella via Libc-alpha wrote:
> The define is already set on the math-use-builtins-ceil.h, the patch
> just removes the implementations (it was missed on c9feb1be93).
> 
> Checked on aarch64-linux-gnu.
> ---
>  sysdeps/aarch64/fpu/s_ceil.c  | 29 -----------------------------
>  sysdeps/aarch64/fpu/s_ceilf.c | 29 -----------------------------
>  2 files changed, 58 deletions(-)
>  delete mode 100644 sysdeps/aarch64/fpu/s_ceil.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_ceilf.c

this is ok to commit.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 04/13] powerpc: Use sqrt{f} builtin
  2020-06-09 21:32 ` [PATCH 04/13] powerpc: Use sqrt{f} builtin Adhemerval Zanella
@ 2020-06-10 14:22   ` Paul A. Clarke
  0 siblings, 0 replies; 29+ messages in thread
From: Paul A. Clarke @ 2020-06-10 14:22 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Tue, Jun 09, 2020 at 06:32:52PM -0300, Adhemerval Zanella via Libc-alpha wrote:
> The powerpc sqrt implementation is also simplified:
> 
>   - the static constants are open coded within the implementation.
>   - for !USE_SQRT_BUILTIN the function is implemented directly on
>     __ieee754_sqrt (it avoid an superflous extra jump).
> 
> Checked on powerpc-linux-gnu and powerpc64le-linux-gnu.
> ---
>  sysdeps/powerpc/fpu/e_sqrt.c                 | 57 ++++++--------------
>  sysdeps/powerpc/fpu/e_sqrtf.c                | 56 ++++++-------------
>  sysdeps/powerpc/fpu/math-use-builtins-sqrt.h |  9 ++++
>  3 files changed, 42 insertions(+), 80 deletions(-)
>  create mode 100644 sysdeps/powerpc/fpu/math-use-builtins-sqrt.h

LGTM.

Reviewed-by: Paul A. Clarke <pc@us.ibm.com>

PC

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 10/13] s390: Use sqrt{f} builtin
  2020-06-09 21:32 ` [PATCH 10/13] s390: " Adhemerval Zanella
@ 2020-06-10 15:39   ` Stefan Liebler
  2020-06-10 15:45     ` Szabolcs Nagy
  0 siblings, 1 reply; 29+ messages in thread
From: Stefan Liebler @ 2020-06-10 15:39 UTC (permalink / raw)
  To: libc-alpha

Hi Adhemerval,

my last tests with the sqrt builtin on s390x showed that gcc emits a
call to libm which would lead to an infinite loop:
if (x < 0)
 sqrt(x)
else
 sqdbr-instruction

Can you have a look into the generated code?
I will also apply your series and perform some test-runs. (next week as
I'll be on vacation the next days)

Then I'll also have a look at the fma-builtins. But those should be fine
for float and double.

Bye.
Stefan

On 6/9/20 11:32 PM, Adhemerval Zanella via Libc-alpha wrote:
> Checked on s390x-linux-gnu.
> ---
>  sysdeps/s390/fpu/e_sqrt.c                 | 30 -----------------------
>  sysdeps/s390/fpu/e_sqrtf.c                | 30 -----------------------
>  sysdeps/s390/fpu/math-use-builtins-sqrt.h |  4 +++
>  3 files changed, 4 insertions(+), 60 deletions(-)
>  delete mode 100644 sysdeps/s390/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/s390/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/s390/fpu/math-use-builtins-sqrt.h
> 
> diff --git a/sysdeps/s390/fpu/e_sqrt.c b/sysdeps/s390/fpu/e_sqrt.c
> deleted file mode 100644
> index 484c6aae95..0000000000
> --- a/sysdeps/s390/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
> -   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -double
> -__ieee754_sqrt (double x)
> -{
> -  double res;
> -
> -  __asm__ ( "sqdbr %0,%1" : "=f" (res) : "f" (x) );
> -  return res;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> diff --git a/sysdeps/s390/fpu/e_sqrtf.c b/sysdeps/s390/fpu/e_sqrtf.c
> deleted file mode 100644
> index bce49c90f1..0000000000
> --- a/sysdeps/s390/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
> -   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -float
> -__ieee754_sqrtf (float x)
> -{
> -  float res;
> -
> -  __asm__ ( "sqebr %0,%1" : "=f" (res) : "f" (x) );
> -  return res;
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> diff --git a/sysdeps/s390/fpu/math-use-builtins-sqrt.h b/sysdeps/s390/fpu/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..e94c915ba6
> --- /dev/null
> +++ b/sysdeps/s390/fpu/math-use-builtins-sqrt.h
> @@ -0,0 +1,4 @@
> +#define USE_SQRT_BUILTIN 1
> +#define USE_SQRTF_BUILTIN 1
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> 


^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 10/13] s390: Use sqrt{f} builtin
  2020-06-10 15:39   ` Stefan Liebler
@ 2020-06-10 15:45     ` Szabolcs Nagy
  2020-06-10 15:59       ` Adhemerval Zanella
  0 siblings, 1 reply; 29+ messages in thread
From: Szabolcs Nagy @ 2020-06-10 15:45 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: libc-alpha

The 06/10/2020 17:39, Stefan Liebler via Libc-alpha wrote:
> Hi Adhemerval,
> 
> my last tests with the sqrt builtin on s390x showed that gcc emits a
> call to libm which would lead to an infinite loop:
> if (x < 0)
>  sqrt(x)
> else
>  sqdbr-instruction

in general the builtins based implementation
must be compiled with -fno-math-errno if
they have error conditions otherwise math-errno
may cause the compiler not to do a single
instruction inline like in this sqrt case.

> 
> Can you have a look into the generated code?
> I will also apply your series and perform some test-runs. (next week as
> I'll be on vacation the next days)
> 
> Then I'll also have a look at the fma-builtins. But those should be fine
> for float and double.
> 
> Bye.
> Stefan
> 
> On 6/9/20 11:32 PM, Adhemerval Zanella via Libc-alpha wrote:
> > Checked on s390x-linux-gnu.
> > ---
> >  sysdeps/s390/fpu/e_sqrt.c                 | 30 -----------------------
> >  sysdeps/s390/fpu/e_sqrtf.c                | 30 -----------------------
> >  sysdeps/s390/fpu/math-use-builtins-sqrt.h |  4 +++
> >  3 files changed, 4 insertions(+), 60 deletions(-)
> >  delete mode 100644 sysdeps/s390/fpu/e_sqrt.c
> >  delete mode 100644 sysdeps/s390/fpu/e_sqrtf.c
> >  create mode 100644 sysdeps/s390/fpu/math-use-builtins-sqrt.h
> > 
> > diff --git a/sysdeps/s390/fpu/e_sqrt.c b/sysdeps/s390/fpu/e_sqrt.c
> > deleted file mode 100644
> > index 484c6aae95..0000000000
> > --- a/sysdeps/s390/fpu/e_sqrt.c
> > +++ /dev/null
> > @@ -1,30 +0,0 @@
> > -/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
> > -   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>.
> > -   This file is part of the GNU C Library.
> > -
> > -   The GNU C Library is free software; you can redistribute it and/or
> > -   modify it under the terms of the GNU Lesser General Public
> > -   License as published by the Free Software Foundation; either
> > -   version 2.1 of the License, or (at your option) any later version.
> > -
> > -   The GNU C Library is distributed in the hope that it will be useful,
> > -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > -   Lesser General Public License for more details.
> > -
> > -   You should have received a copy of the GNU Lesser General Public
> > -   License along with the GNU C Library; if not, see
> > -   <https://www.gnu.org/licenses/>.  */
> > -
> > -#include <math_private.h>
> > -#include <libm-alias-finite.h>
> > -
> > -double
> > -__ieee754_sqrt (double x)
> > -{
> > -  double res;
> > -
> > -  __asm__ ( "sqdbr %0,%1" : "=f" (res) : "f" (x) );
> > -  return res;
> > -}
> > -libm_alias_finite (__ieee754_sqrt, __sqrt)
> > diff --git a/sysdeps/s390/fpu/e_sqrtf.c b/sysdeps/s390/fpu/e_sqrtf.c
> > deleted file mode 100644
> > index bce49c90f1..0000000000
> > --- a/sysdeps/s390/fpu/e_sqrtf.c
> > +++ /dev/null
> > @@ -1,30 +0,0 @@
> > -/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
> > -   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>.
> > -   This file is part of the GNU C Library.
> > -
> > -   The GNU C Library is free software; you can redistribute it and/or
> > -   modify it under the terms of the GNU Lesser General Public
> > -   License as published by the Free Software Foundation; either
> > -   version 2.1 of the License, or (at your option) any later version.
> > -
> > -   The GNU C Library is distributed in the hope that it will be useful,
> > -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> > -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > -   Lesser General Public License for more details.
> > -
> > -   You should have received a copy of the GNU Lesser General Public
> > -   License along with the GNU C Library; if not, see
> > -   <https://www.gnu.org/licenses/>.  */
> > -
> > -#include <math_private.h>
> > -#include <libm-alias-finite.h>
> > -
> > -float
> > -__ieee754_sqrtf (float x)
> > -{
> > -  float res;
> > -
> > -  __asm__ ( "sqebr %0,%1" : "=f" (res) : "f" (x) );
> > -  return res;
> > -}
> > -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> > diff --git a/sysdeps/s390/fpu/math-use-builtins-sqrt.h b/sysdeps/s390/fpu/math-use-builtins-sqrt.h
> > new file mode 100644
> > index 0000000000..e94c915ba6
> > --- /dev/null
> > +++ b/sysdeps/s390/fpu/math-use-builtins-sqrt.h
> > @@ -0,0 +1,4 @@
> > +#define USE_SQRT_BUILTIN 1
> > +#define USE_SQRTF_BUILTIN 1
> > +#define USE_SQRTL_BUILTIN 0
> > +#define USE_SQRTF128_BUILTIN 0
> > 
> 

-- 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 10/13] s390: Use sqrt{f} builtin
  2020-06-10 15:45     ` Szabolcs Nagy
@ 2020-06-10 15:59       ` Adhemerval Zanella
  2020-06-16 10:13         ` Stefan Liebler
  0 siblings, 1 reply; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-10 15:59 UTC (permalink / raw)
  To: libc-alpha



On 10/06/2020 12:45, Szabolcs Nagy wrote:
> The 06/10/2020 17:39, Stefan Liebler via Libc-alpha wrote:
>> Hi Adhemerval,
>>
>> my last tests with the sqrt builtin on s390x showed that gcc emits a
>> call to libm which would lead to an infinite loop:
>> if (x < 0)
>>  sqrt(x)
>> else
>>  sqdbr-instruction
> 
> in general the builtins based implementation
> must be compiled with -fno-math-errno if
> they have error conditions otherwise math-errno
> may cause the compiler not to do a single
> instruction inline like in this sqrt case.

Afaik libm is already build with -fno-math-errno with:

Makeconfig:849:+extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)

And for some implementation (either default or compat ones)
we have specific wrapper (for instance w_sqrt_*) to handle
errno.

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 01/13] math: Decompose math-use-builtins.h
  2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
                   ` (11 preceding siblings ...)
  2020-06-09 21:33 ` [PATCH 13/13] m68k: Use sqrt{f} builtin for coldfire Adhemerval Zanella
@ 2020-06-16 10:13 ` Stefan Liebler
  12 siblings, 0 replies; 29+ messages in thread
From: Stefan Liebler @ 2020-06-16 10:13 UTC (permalink / raw)
  To: libc-alpha

On 6/9/20 11:32 PM, Adhemerval Zanella via Libc-alpha wrote:
> Each symbol definitions are moved on a separated file and it
> cover all symbol type definitions (float, double, long double,
> and float128).
> 
> It allows to set support for architectures without the boiler
> place of copying default values.
> 
> Checked with a build on the affected ABIs.
> ---
>  sysdeps/aarch64/fpu/math-use-builtins-ceil.h  |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins-floor.h |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins-fma.h   |   4 +
>  .../aarch64/fpu/math-use-builtins-nearbyint.h |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins-rint.h  |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins-round.h |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins-sqrt.h  |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins-trunc.h |   4 +
>  sysdeps/aarch64/fpu/math-use-builtins.h       |  71 -----------
>  sysdeps/generic/math-use-builtins-ceil.h      |   4 +
>  sysdeps/generic/math-use-builtins-copysign.h  |   7 ++
>  sysdeps/generic/math-use-builtins-floor.h     |   4 +
>  sysdeps/generic/math-use-builtins-fma.h       |   4 +
>  sysdeps/generic/math-use-builtins-nearbyint.h |   4 +
>  sysdeps/generic/math-use-builtins-rint.h      |   4 +
>  sysdeps/generic/math-use-builtins-round.h     |   4 +
>  sysdeps/generic/math-use-builtins-sqrt.h      |   4 +
>  sysdeps/generic/math-use-builtins-trunc.h     |   4 +
>  sysdeps/generic/math-use-builtins.h           |  56 ++-------
>  sysdeps/powerpc/fpu/math-use-builtins-fma.h   |   9 ++
>  sysdeps/powerpc/fpu/math-use-builtins.h       |  77 ------------
>  sysdeps/s390/fpu/math-use-builtins-ceil.h     |  15 +++
>  sysdeps/s390/fpu/math-use-builtins-floor.h    |  15 +++
>  .../s390/fpu/math-use-builtins-nearbyint.h    |  15 +++
>  sysdeps/s390/fpu/math-use-builtins-rint.h     |  15 +++
>  sysdeps/s390/fpu/math-use-builtins-round.h    |  15 +++
>  sysdeps/s390/fpu/math-use-builtins-trunc.h    |  15 +++
>  sysdeps/s390/fpu/math-use-builtins.h          | 119 ------------------

Hi Adhemerval,

I've applied your patches and successfully run some test builds on
s390x/s390. This patch is okay on s390-perspective.

I assume that it is intended, that there are the defines for
USE_SQRTL_BUILTIN and USE_SQRTF128_BUILTIN although those are currently
not used.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 03/13] s390x: Use fma{f} builtin
  2020-06-09 21:32 ` [PATCH 03/13] s390x: Use fma{f} builtin Adhemerval Zanella
@ 2020-06-16 10:13   ` Stefan Liebler
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Liebler @ 2020-06-16 10:13 UTC (permalink / raw)
  To: libc-alpha

On 6/9/20 11:32 PM, Adhemerval Zanella via Libc-alpha wrote:
> Checked on s390x-linux-gnu.
> ---
>  sysdeps/s390/fpu/math-use-builtins-fma.h |  4 +++
>  sysdeps/s390/fpu/s_fma.c                 | 32 ------------------------
>  sysdeps/s390/fpu/s_fmaf.c                | 32 ------------------------
>  3 files changed, 4 insertions(+), 64 deletions(-)
>  create mode 100644 sysdeps/s390/fpu/math-use-builtins-fma.h
>  delete mode 100644 sysdeps/s390/fpu/s_fma.c
>  delete mode 100644 sysdeps/s390/fpu/s_fmaf.c
> 
> diff --git a/sysdeps/s390/fpu/math-use-builtins-fma.h b/sysdeps/s390/fpu/math-use-builtins-fma.h
> new file mode 100644
> index 0000000000..eede75aa41
> --- /dev/null
> +++ b/sysdeps/s390/fpu/math-use-builtins-fma.h
> @@ -0,0 +1,4 @@
> +#define USE_FMA_BUILTIN 1
> +#define USE_FMAF_BUILTIN 1
> +#define USE_FMAL_BUILTIN 0
> +#define USE_FMAF128_BUILTIN 0
> diff --git a/sysdeps/s390/fpu/s_fma.c b/sysdeps/s390/fpu/s_fma.c
> deleted file mode 100644
> index ae924d05e8..0000000000
> --- a/sysdeps/s390/fpu/s_fma.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/* Compute x * y + z as ternary operation.  S/390 version.
> -   Copyright (C) 2010-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math.h>
> -#include <libm-alias-double.h>
> -
> -double
> -__fma (double x, double y, double z)
> -{
> -  double r;
> -  __asm__ ("madbr %0,%1,%2" : "=f" (r) : "%f" (x), "fR" (y), "0" (z));
> -  return r;
> -}
> -#ifndef __fma
> -libm_alias_double (__fma, fma)
> -#endif
> diff --git a/sysdeps/s390/fpu/s_fmaf.c b/sysdeps/s390/fpu/s_fmaf.c
> deleted file mode 100644
> index 9e5bc533b8..0000000000
> --- a/sysdeps/s390/fpu/s_fmaf.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/* Compute x * y + z as ternary operation.  S/390 version.
> -   Copyright (C) 2010-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math.h>
> -#include <libm-alias-float.h>
> -
> -float
> -__fmaf (float x, float y, float z)
> -{
> -  float r;
> -  __asm__ ("maebr %0,%1,%2" : "=f" (r) : "%f" (x), "fR" (y), "0" (z));
> -  return r;
> -}
> -#ifndef __fmaf
> -libm_alias_float (__fma, fma)
> -#endif
> 


Hi Adhemerval,

I've applied your patches and successfully run some test builds on
s390x/s390. Using the builtins for fma and fmaf works fine.

This patch is okay.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 10/13] s390: Use sqrt{f} builtin
  2020-06-10 15:59       ` Adhemerval Zanella
@ 2020-06-16 10:13         ` Stefan Liebler
  0 siblings, 0 replies; 29+ messages in thread
From: Stefan Liebler @ 2020-06-16 10:13 UTC (permalink / raw)
  To: libc-alpha

On 6/10/20 5:59 PM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 10/06/2020 12:45, Szabolcs Nagy wrote:
>> The 06/10/2020 17:39, Stefan Liebler via Libc-alpha wrote:
>>> Hi Adhemerval,
>>>
>>> my last tests with the sqrt builtin on s390x showed that gcc emits a
>>> call to libm which would lead to an infinite loop:
>>> if (x < 0)
>>>  sqrt(x)
>>> else
>>>  sqdbr-instruction
>>
>> in general the builtins based implementation
>> must be compiled with -fno-math-errno if
>> they have error conditions otherwise math-errno
>> may cause the compiler not to do a single
>> instruction inline like in this sqrt case.
> 
> Afaik libm is already build with -fno-math-errno with:
> 
> Makeconfig:849:+extra-math-flags = $(if $(filter libm,$(in-module)),-fno-math-errno,-fmath-errno)
> 
> And for some implementation (either default or compat ones)
> we have specific wrapper (for instance w_sqrt_*) to handle
> errno.
> 

Hi Adhemerval,

I've applied your patches and successfully run some test builds on
s390x/s390. Using the builtins for sqrt and sqrtf works fine.

This patch is okay.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 05/13] x86_64: Use builtin sqrt{f,l}
  2020-06-09 21:32 ` [PATCH 05/13] x86_64: Use builtin sqrt{f,l} Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:32, Adhemerval Zanella wrote:
> Checked on x86_64-linux-gnu.
> ---
>  sysdeps/x86_64/fpu/e_sqrt.c                 | 32 ---------------------
>  sysdeps/x86_64/fpu/e_sqrtf.c                | 32 ---------------------
>  sysdeps/x86_64/fpu/e_sqrtl.c                | 28 +++++++++++++++++-
>  sysdeps/x86_64/fpu/math-use-builtins-sqrt.h |  4 +++
>  4 files changed, 31 insertions(+), 65 deletions(-)
>  delete mode 100644 sysdeps/x86_64/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/x86_64/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/x86_64/fpu/math-use-builtins-sqrt.h
> 
> diff --git a/sysdeps/x86_64/fpu/e_sqrt.c b/sysdeps/x86_64/fpu/e_sqrt.c
> deleted file mode 100644
> index c1708f9b65..0000000000
> --- a/sysdeps/x86_64/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/* Square root of floating point number.
> -   Copyright (C) 2002-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -#undef __ieee754_sqrt
> -double
> -__ieee754_sqrt (double x)
> -{
> -  double res;
> -
> -  asm ("sqrtsd %1, %0" : "=x" (res) : "xm" (x));
> -
> -  return res;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> diff --git a/sysdeps/x86_64/fpu/e_sqrtf.c b/sysdeps/x86_64/fpu/e_sqrtf.c
> deleted file mode 100644
> index 6155c7be24..0000000000
> --- a/sysdeps/x86_64/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,32 +0,0 @@
> -/* Square root of floating point number.
> -   Copyright (C) 2002-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -#undef __ieee754_sqrtf
> -float
> -__ieee754_sqrtf (float x)
> -{
> -  float res;
> -
> -  asm ("sqrtss %1, %0" : "=x" (res) : "xm" (x));
> -
> -  return res;
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> diff --git a/sysdeps/x86_64/fpu/e_sqrtl.c b/sysdeps/x86_64/fpu/e_sqrtl.c
> index 90e4e164e5..7ea6f52058 100644
> --- a/sysdeps/x86_64/fpu/e_sqrtl.c
> +++ b/sysdeps/x86_64/fpu/e_sqrtl.c
> @@ -1 +1,27 @@
> -#include "sysdeps/i386/fpu/e_sqrtl.c"
> +/* Square root function.  x86_64 long double version.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <math.h>
> +#include <libm-alias-finite.h>
> +
> +long double
> +__ieee754_sqrtl (long double x)
> +{
> +  return __builtin_sqrtl (x);
> +}
> +libm_alias_finite (__ieee754_sqrtl, __sqrtl)
> diff --git a/sysdeps/x86_64/fpu/math-use-builtins-sqrt.h b/sysdeps/x86_64/fpu/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..e94c915ba6
> --- /dev/null
> +++ b/sysdeps/x86_64/fpu/math-use-builtins-sqrt.h
> @@ -0,0 +1,4 @@
> +#define USE_SQRT_BUILTIN 1
> +#define USE_SQRTF_BUILTIN 1
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 13/13] m68k: Use sqrt{f} builtin for coldfire
  2020-06-09 21:33 ` [PATCH 13/13] m68k: Use sqrt{f} builtin for coldfire Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:33, Adhemerval Zanella wrote:
> Checked with a build for m68k-linux-gnu-coldfire.
> ---
>  sysdeps/m68k/coldfire/fpu/e_sqrt.c            | 26 ------------------
>  sysdeps/m68k/coldfire/fpu/e_sqrtf.c           | 27 -------------------
>  .../coldfire/fpu/math-use-builtins-sqrt.h     |  4 +++
>  3 files changed, 4 insertions(+), 53 deletions(-)
>  delete mode 100644 sysdeps/m68k/coldfire/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/m68k/coldfire/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h
> 
> diff --git a/sysdeps/m68k/coldfire/fpu/e_sqrt.c b/sysdeps/m68k/coldfire/fpu/e_sqrt.c
> deleted file mode 100644
> index c67630d1b8..0000000000
> --- a/sysdeps/m68k/coldfire/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <libm-alias-finite.h>
> -
> -double
> -__ieee754_sqrt (double x)
> -{
> -  asm ("fdsqrt.d %1,%0" : "=f" (x) : "fm" (x));
> -  return x;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> diff --git a/sysdeps/m68k/coldfire/fpu/e_sqrtf.c b/sysdeps/m68k/coldfire/fpu/e_sqrtf.c
> deleted file mode 100644
> index c2e4928957..0000000000
> --- a/sysdeps/m68k/coldfire/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Copyright (C) 2006-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <libm-alias-finite.h>
> -
> -float
> -__ieee754_sqrtf (float x)
> -{
> -  double result;
> -  asm ("fssqrt.s %1,%0" : "=f" (result) : "dm" (x));
> -  return result;
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> diff --git a/sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h b/sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..e94c915ba6
> --- /dev/null
> +++ b/sysdeps/m68k/coldfire/fpu/math-use-builtins-sqrt.h
> @@ -0,0 +1,4 @@
> +#define USE_SQRT_BUILTIN 1
> +#define USE_SQRTF_BUILTIN 1
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 07/13] alpha: Use builtin sqrt{f}
  2020-06-09 21:32 ` [PATCH 07/13] alpha: Use builtin sqrt{f} Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:32, Adhemerval Zanella wrote:
> The generic implementation is simplified by removing the
> 'optimization' for !_IEEE_FP_INEXACT (which does not handle
> inexact neither some values).
> 
> Checked on alpha-linux-gnu.
> ---
>  sysdeps/alpha/alphaev6/fpu/e_sqrt.S        |  53 -------
>  sysdeps/alpha/alphaev6/fpu/e_sqrtf.S       |  53 -------
>  sysdeps/alpha/fpu/e_sqrt.c                 | 164 +--------------------
>  sysdeps/alpha/fpu/e_sqrtf.c                |   9 +-
>  sysdeps/alpha/fpu/math-use-builtins-sqrt.h |   9 ++
>  5 files changed, 13 insertions(+), 275 deletions(-)
>  delete mode 100644 sysdeps/alpha/alphaev6/fpu/e_sqrt.S
>  delete mode 100644 sysdeps/alpha/alphaev6/fpu/e_sqrtf.S
>  create mode 100644 sysdeps/alpha/fpu/math-use-builtins-sqrt.h
> 
> diff --git a/sysdeps/alpha/alphaev6/fpu/e_sqrt.S b/sysdeps/alpha/alphaev6/fpu/e_sqrt.S
> deleted file mode 100644
> index 33596e2ed3..0000000000
> --- a/sysdeps/alpha/alphaev6/fpu/e_sqrt.S
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <sysdep.h>
> -#include <shlib-compat.h>
> -
> -	.arch ev6
> -	.set noreorder
> -	.set noat
> -
> -ENTRY(__ieee754_sqrt)
> -#ifdef PROF
> -	ldgp    gp, 0(pv)
> -	lda     AT, _mcount
> -	jsr     AT, (AT), _mcount
> -	.prologue 1
> -#else
> -	.prologue 0
> -#endif
> -
> -	.align 4
> -#ifdef _IEEE_FP_INEXACT
> -	sqrtt/suid $f16, $f0
> -#else
> -	sqrtt/sud $f16, $f0
> -#endif
> -	ret
> -	nop
> -	nop
> -
> -END(__ieee754_sqrt)
> -
> -#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
> -strong_alias(__ieee754_sqrt, __sqrt_dummy)
> -compat_symbol(libm, __sqrt_dummy, __sqrt_finite, GLIBC_2_15)
> -#endif
> -#if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
> -compat_symbol(libm, __ieee754_sqrt, __sqrt_finite, GLIBC_2_18)
> -#endif
> diff --git a/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S b/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S
> deleted file mode 100644
> index 36e04cce38..0000000000
> --- a/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S
> +++ /dev/null
> @@ -1,53 +0,0 @@
> -/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <sysdep.h>
> -#include <shlib-compat.h>
> -
> -	.arch ev6
> -	.set noreorder
> -	.set noat
> -
> -ENTRY(__ieee754_sqrtf)
> -#ifdef PROF
> -	ldgp    gp, 0(pv)
> -	lda     AT, _mcount
> -	jsr     AT, (AT), _mcount
> -	.prologue 1
> -#else
> -	.prologue 0
> -#endif
> -
> -	.align 4
> -#ifdef _IEEE_FP_INEXACT
> -	sqrts/suid $f16, $f0
> -#else
> -	sqrts/sud $f16, $f0
> -#endif
> -	ret
> -	nop
> -	nop
> -
> -END(__ieee754_sqrtf)
> -
> -#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
> -strong_alias(__ieee754_sqrtf, __sqrtf_dummy)
> -compat_symbol(libm, __sqrtf_dummy, __sqrtf_finite, GLIBC_2_15)
> -#endif
> -#if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
> -compat_symbol(libm, __ieee754_sqrtf, __sqrtf_finite, GLIBC_2_18)
> -#endif
> diff --git a/sysdeps/alpha/fpu/e_sqrt.c b/sysdeps/alpha/fpu/e_sqrt.c
> index 4cf2ad693a..c75ed07bd6 100644
> --- a/sysdeps/alpha/fpu/e_sqrt.c
> +++ b/sysdeps/alpha/fpu/e_sqrt.c
> @@ -16,171 +16,11 @@
>     License along with the GNU C Library.  If not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <math.h>
> -#include <math_private.h>
>  #include <shlib-compat.h>
>  
> -#if !defined(_IEEE_FP_INEXACT)
> -
> -/*
> - * This version is much faster than generic sqrt implementation, but
> - * it doesn't handle the inexact flag.  It doesn't handle exceptional
> - * values either, but will defer to the full ieee754_sqrt routine which
> - * can.
> - */
> -
> -/* Careful with rearranging this without consulting the assembly below.  */
> -const static struct sqrt_data_struct {
> -	unsigned long dn, up, half, almost_three_half;
> -	unsigned long one_and_a_half, two_to_minus_30, one, nan;
> -	const int T2[64];
> -} sqrt_data __attribute__((used)) = {
> -	0x3fefffffffffffff,	/* __dn = nextafter(1,-Inf) */
> -	0x3ff0000000000001,	/* __up = nextafter(1,+Inf) */
> -	0x3fe0000000000000,	/* half */
> -	0x3ff7ffffffc00000,	/* almost_three_half = 1.5-2^-30 */
> -	0x3ff8000000000000,	/* one_and_a_half */
> -	0x3e10000000000000,	/* two_to_minus_30 */
> -	0x3ff0000000000000,	/* one */
> -	0xffffffffffffffff,	/* nan */
> -
> -	{ 0x1500, 0x2ef8, 0x4d67, 0x6b02, 0x87be, 0xa395, 0xbe7a, 0xd866,
> -	0xf14a, 0x1091b,0x11fcd,0x13552,0x14999,0x15c98,0x16e34,0x17e5f,
> -	0x18d03,0x19a01,0x1a545,0x1ae8a,0x1b5c4,0x1bb01,0x1bfde,0x1c28d,
> -	0x1c2de,0x1c0db,0x1ba73,0x1b11c,0x1a4b5,0x1953d,0x18266,0x16be0,
> -	0x1683e,0x179d8,0x18a4d,0x19992,0x1a789,0x1b445,0x1bf61,0x1c989,
> -	0x1d16d,0x1d77b,0x1dddf,0x1e2ad,0x1e5bf,0x1e6e8,0x1e654,0x1e3cd,
> -	0x1df2a,0x1d635,0x1cb16,0x1be2c,0x1ae4e,0x19bde,0x1868e,0x16e2e,
> -	0x1527f,0x1334a,0x11051,0xe951, 0xbe01, 0x8e0d, 0x5924, 0x1edd }
> -};
> -
> -asm ("\
> -  /* Define offsets into the structure defined in C above.  */		\n\
> -	$DN = 0*8							\n\
> -	$UP = 1*8							\n\
> -	$HALF = 2*8							\n\
> -	$ALMOST_THREE_HALF = 3*8					\n\
> -	$NAN = 7*8							\n\
> -	$T2 = 8*8							\n\
> -									\n\
> -  /* Stack variables.  */						\n\
> -	$K = 0								\n\
> -	$Y = 8								\n\
> -									\n\
> -	.text								\n\
> -	.align	5							\n\
> -	.globl	__ieee754_sqrt						\n\
> -	.ent	__ieee754_sqrt						\n\
> -__ieee754_sqrt:								\n\
> -	ldgp	$29, 0($27)						\n\
> -	subq	$sp, 16, $sp						\n\
> -	.frame	$sp, 16, $26, 0\n"
> -#ifdef PROF
> -"	lda	$28, _mcount						\n\
> -	jsr	$28, ($28), _mcount\n"
> -#endif
> -"	.prologue 1							\n\
> -									\n\
> -	.align 4							\n\
> -	stt	$f16, $K($sp)		# e0    :			\n\
> -	mult	$f31, $f31, $f31	# .. fm :			\n\
> -	lda	$4, sqrt_data		# e0    :			\n\
> -	fblt	$f16, $fixup		# .. fa :			\n\
> -									\n\
> -	ldah	$2, 0x5fe8		# e0    :			\n\
> -	ldq	$3, $K($sp)		# .. e1 :			\n\
> -	ldt	$f12, $HALF($4)		# e0    :			\n\
> -	ldt	$f18, $ALMOST_THREE_HALF($4)	# .. e1 :		\n\
> -									\n\
> -	sll	$3, 52, $5		# e0    :			\n\
> -	lda	$6, 0x7fd		# .. e1 :			\n\
> -	fnop				# .. fa :			\n\
> -	fnop				# .. fm :			\n\
> -									\n\
> -	subq	$5, 1, $5		# e1    :			\n\
> -	srl	$3, 33, $1		# .. e0 :			\n\
> -	cmpule	$5, $6, $5		# e0    :			\n\
> -	beq	$5, $fixup		# .. e1 :			\n\
> -									\n\
> -	mult	$f16, $f12, $f11	# fm    : $f11 = x * 0.5	\n\
> -	subl	$2, $1, $2		# .. e0 :			\n\
> -	addt	$f12, $f12, $f17	# .. fa : $f17 = 1.0		\n\
> -	srl	$2, 12, $1		# e0    :			\n\
> -									\n\
> -	and	$1, 0xfc, $1		# e0    :			\n\
> -	addq	$1, $4, $1		# e1    :			\n\
> -	ldl	$1, $T2($1)		# e0    :			\n\
> -	addt	$f12, $f17, $f15	# .. fa : $f15 = 1.5		\n\
> -									\n\
> -	subl	$2, $1, $2		# e0    :			\n\
> -	ldt	$f14, $DN($4)		# .. e1 :			\n\
> -	sll	$2, 32, $2		# e0    :			\n\
> -	stq	$2, $Y($sp)		# e0    :			\n\
> -									\n\
> -	ldt	$f13, $Y($sp)		# e0    :			\n\
> -	mult/su	$f11, $f13, $f10	# fm   2: $f10 = (x * 0.5) * y	\n\
> -	mult	$f10, $f13, $f10	# fm   4: $f10 = ((x*0.5)*y)*y	\n\
> -	subt	$f15, $f10, $f1		# fa   4: $f1 = (1.5-0.5*x*y*y)	\n\
> -									\n\
> -	mult	$f13, $f1, $f13         # fm   4: yp = y*(1.5-0.5*x*y^2)\n\
> -	mult/su	$f11, $f13, $f1		# fm   4: $f11 = x * 0.5 * yp	\n\
> -	mult	$f1, $f13, $f11		# fm   4: $f11 = (x*0.5*yp)*yp	\n\
> -	subt	$f18, $f11, $f1		# fa   4: $f1=(1.5-2^-30)-x/2*yp^2\n\
> -									\n\
> -	mult	$f13, $f1, $f13		# fm   4: ypp = $f13 = yp*$f1	\n\
> -	subt	$f15, $f12, $f1		# .. fa : $f1 = (1.5 - 0.5)	\n\
> -	ldt	$f15, $UP($4)		# .. e0 :			\n\
> -	mult/su	$f16, $f13, $f10	# fm   4: z = $f10 = x * ypp	\n\
> -									\n\
> -	mult	$f10, $f13, $f11	# fm   4: $f11 = z*ypp		\n\
> -	mult	$f10, $f12, $f12	# fm    : $f12 = z*0.5		\n\
> -	subt	$f1, $f11, $f1		# fa   4: $f1 = 1 - z*ypp	\n\
> -	mult	$f12, $f1, $f12		# fm   4: $f12 = z/2*(1 - z*ypp)\n\
> -									\n\
> -	addt	$f10, $f12, $f0		# fa   4: zp=res= z+z/2*(1-z*ypp)\n\
> -	mult/c	$f0, $f14, $f12		# fm   4: zmi = zp * DN		\n\
> -	mult/c	$f0, $f15, $f11		# fm    : zpl = zp * UP		\n\
> -	mult/c	$f0, $f12, $f1		# fm    : $f1 = zp * zmi	\n\
> -									\n\
> -	mult/c	$f0, $f11, $f15		# fm    : $f15 = zp * zpl	\n\
> -	subt/su	$f1, $f16, $f13		# .. fa : y1 = zp*zmi - x	\n\
> -	subt/su	$f15, $f16, $f14	# fa   4: y2 = zp*zpl - x	\n\
> -	fcmovge	$f13, $f12, $f0		# fa   3: res = (y1>=0)?zmi:res	\n\
> -									\n\
> -	fcmovlt	$f14, $f11, $f0		# fa   4: res = (y2<0)?zpl:res	\n\
> -	addq	$sp, 16, $sp		# .. e0 :			\n\
> -	ret				# .. e1 :			\n\
> -									\n\
> -	.align 4							\n\
> -$fixup:									\n\
> -	addq	$sp, 16, $sp						\n\
> -	br	__full_ieee754_sqrt	!samegp				\n\
> -									\n\
> -	.end	__ieee754_sqrt");
> -
> -#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
> -asm (".global  __sqrt_dummy; __sqrt_dummy = __ieee754_sqrt");
> -#else
> -asm (".global  __sqrt_finite; __sqrt_finite = __ieee754_sqrt");
> -#endif
> -
> -static double __full_ieee754_sqrt(double) __attribute_used__;
> -#define __ieee754_sqrt __full_ieee754_sqrt
> -
> -#elif SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
> -
> -strong_alias (__ieee754_sqrt, __sqrt_dummy)
> -#define __ieee754_sqrt __ieee754_sqrt
> -
> -#endif /* _IEEE_FP_INEXACT */
> -
>  #include <sysdeps/ieee754/dbl-64/e_sqrt.c>
> -#undef __ieee754_sqrt
>  
> -/* Work around forgotten symbol in alphaev6 build.  */
> -#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
> -compat_symbol (libm, __sqrt_dummy, __sqrt_finite, GLIBC_2_15);
> -#endif
>  #if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
> -compat_symbol (libm, __ieee754_sqrt, __sqrt_finite, GLIBC_2_18);
> +strong_alias (__ieee754_sqrt, __sqrt_finite_2_18)
> +compat_symbol (libm, __sqrt_finite_2_18, __sqrt_finite, GLIBC_2_18);
>  #endif
> diff --git a/sysdeps/alpha/fpu/e_sqrtf.c b/sysdeps/alpha/fpu/e_sqrtf.c
> index eb3f968576..38c41db537 100644
> --- a/sysdeps/alpha/fpu/e_sqrtf.c
> +++ b/sysdeps/alpha/fpu/e_sqrtf.c
> @@ -1,13 +1,8 @@
>  #include <shlib-compat.h>
>  
> -#define __ieee754_sqrtf __ieee754_sqrtf
>  #include <sysdeps/ieee754/flt-32/e_sqrtf.c>
>  
> -/* Work around forgotten symbol in alphaev6 build.  */
> -#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18)
> -strong_alias(__ieee754_sqrtf, __sqrtf_dummy)
> -compat_symbol (libm, __sqrtf_dummy, __sqrtf_finite, GLIBC_2_15);
> -#endif
>  #if SHLIB_COMPAT (libm, GLIBC_2_18, GLIBC_2_31)
> -compat_symbol (libm, __ieee754_sqrtf, __sqrtf_finite, GLIBC_2_18);
> +strong_alias (__ieee754_sqrtf, __sqrtf_finite_2_18)
> +compat_symbol (libm, __sqrtf_finite_2_18, __sqrtf_finite, GLIBC_2_18);
>  #endif
> diff --git a/sysdeps/alpha/fpu/math-use-builtins-sqrt.h b/sysdeps/alpha/fpu/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..550b097ed6
> --- /dev/null
> +++ b/sysdeps/alpha/fpu/math-use-builtins-sqrt.h
> @@ -0,0 +1,9 @@
> +#ifdef __alpha_ev6__
> +# define USE_SQRT_BUILTIN 1
> +# define USE_SQRTF_BUILTIN 1
> +#else
> +# define USE_SQRT_BUILTIN 0
> +# define USE_SQRTF_BUILTIN 0
> +#endif
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 08/13] mips: Use sqrt{f} builtin
  2020-06-09 21:32 ` [PATCH 08/13] mips: Use sqrt{f} builtin Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:32, Adhemerval Zanella wrote:
> Checked with a build against mips-linux-gnu and mips64-linux-gnu
> and comparing the resulting binaries.
> ---
>  sysdeps/mips/fpu/e_sqrt.c                 | 38 -----------------------
>  sysdeps/mips/fpu/e_sqrtf.c                | 38 -----------------------
>  sysdeps/mips/fpu/math-use-builtins-sqrt.h |  6 ++++
>  sysdeps/mips/mips32/fpu/e_sqrt.c          |  1 -
>  sysdeps/mips/mips32/fpu/e_sqrtf.c         |  1 -
>  sysdeps/mips/mips64/n32/fpu/e_sqrt.c      |  1 -
>  sysdeps/mips/mips64/n32/fpu/e_sqrtf.c     |  1 -
>  sysdeps/mips/mips64/n64/fpu/e_sqrt.c      |  1 -
>  sysdeps/mips/mips64/n64/fpu/e_sqrtf.c     |  1 -
>  9 files changed, 6 insertions(+), 82 deletions(-)
>  delete mode 100644 sysdeps/mips/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/mips/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/mips/fpu/math-use-builtins-sqrt.h
>  delete mode 100644 sysdeps/mips/mips32/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/mips/mips32/fpu/e_sqrtf.c
>  delete mode 100644 sysdeps/mips/mips64/n32/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/mips/mips64/n32/fpu/e_sqrtf.c
>  delete mode 100644 sysdeps/mips/mips64/n64/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/mips/mips64/n64/fpu/e_sqrtf.c
> 
> diff --git a/sysdeps/mips/fpu/e_sqrt.c b/sysdeps/mips/fpu/e_sqrt.c
> deleted file mode 100644
> index 47488e993c..0000000000
> --- a/sysdeps/mips/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -#include <sgidefs.h>
> -#include <libm-alias-finite.h>
> -
> -#if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
> -
> -double __attribute__ ((nomips16))
> -__ieee754_sqrt (double x)
> -{
> -  double z;
> -  __asm__ ("sqrt.d %0,%1" : "=f" (z) : "f" (x));
> -  return z;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> -
> -#else
> -
> -#include <sysdeps/ieee754/dbl-64/e_sqrt.c>
> -
> -#endif
> diff --git a/sysdeps/mips/fpu/e_sqrtf.c b/sysdeps/mips/fpu/e_sqrtf.c
> deleted file mode 100644
> index dc33788bf3..0000000000
> --- a/sysdeps/mips/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -   Contributed by Hartvig Ekner <hartvige@mips.com>, 2002.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -#include <sgidefs.h>
> -#include <libm-alias-finite.h>
> -
> -#if (_MIPS_ISA >= _MIPS_ISA_MIPS2)
> -
> -float __attribute__ ((nomips16))
> -__ieee754_sqrtf (float x)
> -{
> -  float z;
> -  __asm__ ("sqrt.s %0,%1" : "=f" (z) : "f" (x));
> -  return z;
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> -
> -#else
> -
> -#include <sysdeps/ieee754/flt-32/e_sqrtf.c>
> -
> -#endif
> diff --git a/sysdeps/mips/fpu/math-use-builtins-sqrt.h b/sysdeps/mips/fpu/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..37f49ebc9f
> --- /dev/null
> +++ b/sysdeps/mips/fpu/math-use-builtins-sqrt.h
> @@ -0,0 +1,6 @@
> +#include <sgidefs.h>
> +
> +#define USE_SQRT_BUILTIN (_MIPS_ISA >= _MIPS_ISA_MIPS2)
> +#define USE_SQRTF_BUILTIN (_MIPS_ISA >= _MIPS_ISA_MIPS2)
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> diff --git a/sysdeps/mips/mips32/fpu/e_sqrt.c b/sysdeps/mips/mips32/fpu/e_sqrt.c
> deleted file mode 100644
> index 81f4e77697..0000000000
> --- a/sysdeps/mips/mips32/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/mips/fpu/e_sqrt.c>
> diff --git a/sysdeps/mips/mips32/fpu/e_sqrtf.c b/sysdeps/mips/mips32/fpu/e_sqrtf.c
> deleted file mode 100644
> index fb0700d45c..0000000000
> --- a/sysdeps/mips/mips32/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/mips/fpu/e_sqrtf.c>
> diff --git a/sysdeps/mips/mips64/n32/fpu/e_sqrt.c b/sysdeps/mips/mips64/n32/fpu/e_sqrt.c
> deleted file mode 100644
> index 81f4e77697..0000000000
> --- a/sysdeps/mips/mips64/n32/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/mips/fpu/e_sqrt.c>
> diff --git a/sysdeps/mips/mips64/n32/fpu/e_sqrtf.c b/sysdeps/mips/mips64/n32/fpu/e_sqrtf.c
> deleted file mode 100644
> index fb0700d45c..0000000000
> --- a/sysdeps/mips/mips64/n32/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/mips/fpu/e_sqrtf.c>
> diff --git a/sysdeps/mips/mips64/n64/fpu/e_sqrt.c b/sysdeps/mips/mips64/n64/fpu/e_sqrt.c
> deleted file mode 100644
> index 81f4e77697..0000000000
> --- a/sysdeps/mips/mips64/n64/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/mips/fpu/e_sqrt.c>
> diff --git a/sysdeps/mips/mips64/n64/fpu/e_sqrtf.c b/sysdeps/mips/mips64/n64/fpu/e_sqrtf.c
> deleted file mode 100644
> index fb0700d45c..0000000000
> --- a/sysdeps/mips/mips64/n64/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/mips/fpu/e_sqrtf.c>
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 09/13] sparc: Use sqrt{f} builtin
  2020-06-09 21:32 ` [PATCH 09/13] sparc: " Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:32, Adhemerval Zanella wrote:
> It also enabled to use fsqrtd on sparc64.
> 
> Checked on sparcv9-linux-gnu and sparc64-linux-gnu.
> ---
>  sysdeps/sparc/fpu/math-use-builtins-sqrt.h |  4 +++
>  sysdeps/sparc/sparc32/e_sqrt.c             | 34 ----------------------
>  2 files changed, 4 insertions(+), 34 deletions(-)
>  create mode 100644 sysdeps/sparc/fpu/math-use-builtins-sqrt.h
>  delete mode 100644 sysdeps/sparc/sparc32/e_sqrt.c
> 
> diff --git a/sysdeps/sparc/fpu/math-use-builtins-sqrt.h b/sysdeps/sparc/fpu/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..e94c915ba6
> --- /dev/null
> +++ b/sysdeps/sparc/fpu/math-use-builtins-sqrt.h
> @@ -0,0 +1,4 @@
> +#define USE_SQRT_BUILTIN 1
> +#define USE_SQRTF_BUILTIN 1
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> diff --git a/sysdeps/sparc/sparc32/e_sqrt.c b/sysdeps/sparc/sparc32/e_sqrt.c
> deleted file mode 100644
> index e8a42c4d7b..0000000000
> --- a/sysdeps/sparc/sparc32/e_sqrt.c
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <errno.h>
> -#include <math.h>
> -#include <libm-alias-finite.h>
> -
> -#ifndef	__GNUC__
> -  #error This file uses GNU C extensions; you must compile with GCC.
> -#endif
> -
> -/* Return the square root of X.  */
> -double
> -__ieee754_sqrt (double x)
> -{
> -  register double result;
> -  asm ("fsqrtd %1, %0" : "=f" (result) : "f" (x));
> -  return result;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 06/13] i386: Use builtin sqrtl
  2020-06-09 21:32 ` [PATCH 06/13] i386: Use builtin sqrtl Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:32, Adhemerval Zanella wrote:
> Checked on i686-linux-gnu.
> ---
>  sysdeps/i386/fpu/e_sqrtl.c            | 21 ---------------------
>  sysdeps/{x86_64 => x86}/fpu/e_sqrtl.c |  0
>  2 files changed, 21 deletions(-)
>  delete mode 100644 sysdeps/i386/fpu/e_sqrtl.c
>  rename sysdeps/{x86_64 => x86}/fpu/e_sqrtl.c (100%)
> 
> diff --git a/sysdeps/i386/fpu/e_sqrtl.c b/sysdeps/i386/fpu/e_sqrtl.c
> deleted file mode 100644
> index 8f284dd75c..0000000000
> --- a/sysdeps/i386/fpu/e_sqrtl.c
> +++ /dev/null
> @@ -1,21 +0,0 @@
> -/*
> - * Written by J.T. Conklin <jtc@netbsd.org>.
> - * Public domain.
> - *
> - * Adapted for `long double' by Ulrich Drepper <drepper@cygnus.com>.
> - */
> -
> -#include <math_private.h>
> -#include <libm-alias-finite.h>
> -
> -#undef __ieee754_sqrtl
> -long double
> -__ieee754_sqrtl (long double x)
> -{
> -  long double res;
> -
> -  asm ("fsqrt" : "=t" (res) : "0" (x));
> -
> -  return res;
> -}
> -libm_alias_finite (__ieee754_sqrtl, __sqrtl)
> diff --git a/sysdeps/x86_64/fpu/e_sqrtl.c b/sysdeps/x86/fpu/e_sqrtl.c
> similarity index 100%
> rename from sysdeps/x86_64/fpu/e_sqrtl.c
> rename to sysdeps/x86/fpu/e_sqrtl.c
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 11/13] riscv: Use sqrt{f} builtin
  2020-06-09 21:32 ` [PATCH 11/13] riscv: " Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:32, Adhemerval Zanella wrote:
> Checked with a build for riscv64-linux-gnu-rv64imac-lp64 (no
> builtin support), riscv64-linux-gnu-rv64imafdc-lp64, and
> riscv64-linux-gnu-rv64imafdc-lp64d.
> ---
>  sysdeps/riscv/rvd/e_sqrt.c                 | 28 ----------------------
>  sysdeps/riscv/rvd/math-use-builtins-sqrt.h |  4 ++++
>  sysdeps/riscv/rvf/e_sqrtf.c                | 28 ----------------------
>  3 files changed, 4 insertions(+), 56 deletions(-)
>  delete mode 100644 sysdeps/riscv/rvd/e_sqrt.c
>  create mode 100644 sysdeps/riscv/rvd/math-use-builtins-sqrt.h
>  delete mode 100644 sysdeps/riscv/rvf/e_sqrtf.c
> 
> diff --git a/sysdeps/riscv/rvd/e_sqrt.c b/sysdeps/riscv/rvd/e_sqrt.c
> deleted file mode 100644
> index 7defcb5785..0000000000
> --- a/sysdeps/riscv/rvd/e_sqrt.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Double precision floating point square root.  RISC-V version.
> -   Copyright (C) 2017-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math.h>
> -#include <libm-alias-finite.h>
> -
> -double
> -__ieee754_sqrt (double x)
> -{
> -  asm ("fsqrt.d %0, %1" : "=f" (x) : "f" (x));
> -  return x;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> diff --git a/sysdeps/riscv/rvd/math-use-builtins-sqrt.h b/sysdeps/riscv/rvd/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..e94c915ba6
> --- /dev/null
> +++ b/sysdeps/riscv/rvd/math-use-builtins-sqrt.h
> @@ -0,0 +1,4 @@
> +#define USE_SQRT_BUILTIN 1
> +#define USE_SQRTF_BUILTIN 1
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> diff --git a/sysdeps/riscv/rvf/e_sqrtf.c b/sysdeps/riscv/rvf/e_sqrtf.c
> deleted file mode 100644
> index 04835e3e53..0000000000
> --- a/sysdeps/riscv/rvf/e_sqrtf.c
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Single precision floating point square root.  RISC-V version.
> -   Copyright (C) 2017-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#include <math.h>
> -#include <libm-alias-finite.h>
> -
> -float
> -__ieee754_sqrtf (float x)
> -{
> -  asm ("fsqrt.s %0, %1" : "=f" (x) : "f" (x));
> -  return x;
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

* Re: [PATCH 12/13] arm: Use sqrt{f} builtin
  2020-06-09 21:33 ` [PATCH 12/13] arm: " Adhemerval Zanella
@ 2020-06-19 19:17   ` Adhemerval Zanella
  0 siblings, 0 replies; 29+ messages in thread
From: Adhemerval Zanella @ 2020-06-19 19:17 UTC (permalink / raw)
  To: libc-alpha

If no one opposes I will commit this.

On 09/06/2020 18:33, Adhemerval Zanella wrote:
> Checked on arm-linux-gnueabi and armv7-linux-gnueabihf
> ---
>  sysdeps/arm/e_sqrt.c                 | 46 ----------------------------
>  sysdeps/arm/e_sqrtf.c                | 46 ----------------------------
>  sysdeps/arm/math-use-builtins-sqrt.h |  9 ++++++
>  3 files changed, 9 insertions(+), 92 deletions(-)
>  delete mode 100644 sysdeps/arm/e_sqrt.c
>  delete mode 100644 sysdeps/arm/e_sqrtf.c
>  create mode 100644 sysdeps/arm/math-use-builtins-sqrt.h
> 
> diff --git a/sysdeps/arm/e_sqrt.c b/sysdeps/arm/e_sqrt.c
> deleted file mode 100644
> index d264c4263b..0000000000
> --- a/sysdeps/arm/e_sqrt.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/* Compute square root for double.  ARM version.
> -   Copyright (C) 2016-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#ifdef __SOFTFP__
> -
> -/* Use architecture-indendent sqrt implementation.  */
> -# include <sysdeps/ieee754/dbl-64/e_sqrt.c>
> -
> -#else
> -
> -/* Use VFP square root instruction.  */
> -# include <math.h>
> -# include <sysdep.h>
> -# include <libm-alias-finite.h>
> -
> -double
> -__ieee754_sqrt (double x)
> -{
> -  double ret;
> -# if __ARM_ARCH >= 6
> -  asm ("vsqrt.f64 %P0, %P1" : "=w" (ret) : "w" (x));
> -# else
> -  /* As in GCC, for VFP9 Erratum 760019 avoid overwriting the
> -     input.  */
> -  asm ("vsqrt.f64 %P0, %P1" : "=&w" (ret) : "w" (x));
> -# endif
> -  return ret;
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)
> -
> -#endif
> diff --git a/sysdeps/arm/e_sqrtf.c b/sysdeps/arm/e_sqrtf.c
> deleted file mode 100644
> index c3f31119a3..0000000000
> --- a/sysdeps/arm/e_sqrtf.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/* Compute square root for float.  ARM version.
> -   Copyright (C) 2016-2020 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -#ifdef __SOFTFP__
> -
> -/* Use architecture-indendent sqrtf implementation.  */
> -# include <sysdeps/ieee754/flt-32/e_sqrtf.c>
> -
> -#else
> -
> -/* Use VFP square root instruction.  */
> -# include <math.h>
> -# include <sysdep.h>
> -# include <libm-alias-finite.h>
> -
> -float
> -__ieee754_sqrtf (float x)
> -{
> -  float ret;
> -# if __ARM_ARCH >= 6
> -  asm ("vsqrt.f32 %0, %1" : "=t" (ret) : "t" (x));
> -# else
> -  /* As in GCC, for VFP9 Erratum 760019 avoid overwriting the
> -     input.  */
> -  asm ("vsqrt.f32 %0, %1" : "=&t" (ret) : "t" (x));
> -# endif
> -  return ret;
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> -
> -#endif
> diff --git a/sysdeps/arm/math-use-builtins-sqrt.h b/sysdeps/arm/math-use-builtins-sqrt.h
> new file mode 100644
> index 0000000000..e765e7c49d
> --- /dev/null
> +++ b/sysdeps/arm/math-use-builtins-sqrt.h
> @@ -0,0 +1,9 @@
> +#ifdef __SOFTFP__
> +# define USE_SQRT_BUILTIN 0
> +# define USE_SQRTF_BUILTIN 0
> +#else
> +# define USE_SQRT_BUILTIN 1
> +# define USE_SQRTF_BUILTIN 1
> +#endif
> +#define USE_SQRTL_BUILTIN 0
> +#define USE_SQRTF128_BUILTIN 0
> 

^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2020-06-19 19:17 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09 21:32 [PATCH 01/13] math: Decompose math-use-builtins.h Adhemerval Zanella
2020-06-09 21:32 ` [PATCH 02/13] aarch64: Use math-use-builtins for ceil{f} Adhemerval Zanella
2020-06-10 10:15   ` Szabolcs Nagy
2020-06-09 21:32 ` [PATCH 03/13] s390x: Use fma{f} builtin Adhemerval Zanella
2020-06-16 10:13   ` Stefan Liebler
2020-06-09 21:32 ` [PATCH 04/13] powerpc: Use sqrt{f} builtin Adhemerval Zanella
2020-06-10 14:22   ` Paul A. Clarke
2020-06-09 21:32 ` [PATCH 05/13] x86_64: Use builtin sqrt{f,l} Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:32 ` [PATCH 06/13] i386: Use builtin sqrtl Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:32 ` [PATCH 07/13] alpha: Use builtin sqrt{f} Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:32 ` [PATCH 08/13] mips: Use sqrt{f} builtin Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:32 ` [PATCH 09/13] sparc: " Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:32 ` [PATCH 10/13] s390: " Adhemerval Zanella
2020-06-10 15:39   ` Stefan Liebler
2020-06-10 15:45     ` Szabolcs Nagy
2020-06-10 15:59       ` Adhemerval Zanella
2020-06-16 10:13         ` Stefan Liebler
2020-06-09 21:32 ` [PATCH 11/13] riscv: " Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:33 ` [PATCH 12/13] arm: " Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-09 21:33 ` [PATCH 13/13] m68k: Use sqrt{f} builtin for coldfire Adhemerval Zanella
2020-06-19 19:17   ` Adhemerval Zanella
2020-06-16 10:13 ` [PATCH 01/13] math: Decompose math-use-builtins.h Stefan Liebler

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).