[12/17] S390: Use copy-sign instruction for copysign functions.

Message ID 1572881244-6781-12-git-send-email-stli@linux.ibm.com
State Superseded
Headers

Commit Message

Stefan Liebler Nov. 4, 2019, 3:27 p.m. UTC
  If compiled with z10 zarch support, the copy-sign instruction
is used to implement copysign, copysignf, copysignl.
Otherwise the common-code implementation is used.
---
 sysdeps/s390/fpu/s_copysign.c  | 39 ++++++++++++++++++++++++++++++++
 sysdeps/s390/fpu/s_copysignf.c | 35 +++++++++++++++++++++++++++++
 sysdeps/s390/fpu/s_copysignl.c | 41 ++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100644 sysdeps/s390/fpu/s_copysign.c
 create mode 100644 sysdeps/s390/fpu/s_copysignf.c
 create mode 100644 sysdeps/s390/fpu/s_copysignl.c
  

Comments

Stefan Liebler Dec. 2, 2019, 2:57 p.m. UTC | #1
This patch is superseded by the patch-series which is always using 
wordsize-64 version and allows to use the GCC builtins in common-code 
implementation:
"[PATCH 00/13] Use GCC builtins for some math functions if desired."
https://www.sourceware.org/ml/libc-alpha/2019-12/msg00029.html

Bye,
Stefan
  

Patch

diff --git a/sysdeps/s390/fpu/s_copysign.c b/sysdeps/s390/fpu/s_copysign.c
new file mode 100644
index 0000000000..f62d86b925
--- /dev/null
+++ b/sysdeps/s390/fpu/s_copysign.c
@@ -0,0 +1,39 @@ 
+/* copysign() - S390 version.
+   Copyright (C) 2019 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/>.  */
+
+#if defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT
+# define NO_MATH_REDIRECT
+# include <math.h>
+# include <libm-alias-double.h>
+# include <math_ldbl_opt.h>
+
+double
+__copysign (double x, double y)
+{
+  __asm__ ("cpsdr %0,%1,%0" : "+f" (x) : "f" (y));
+  return x;
+}
+libm_alias_double (__copysign, copysign)
+# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+compat_symbol (libc, __copysign, copysignl, GLIBC_2_0);
+# endif
+
+#else
+# include <sysdeps/ieee754/ldbl-opt/s_copysign.c>
+#endif
diff --git a/sysdeps/s390/fpu/s_copysignf.c b/sysdeps/s390/fpu/s_copysignf.c
new file mode 100644
index 0000000000..017f558486
--- /dev/null
+++ b/sysdeps/s390/fpu/s_copysignf.c
@@ -0,0 +1,35 @@ 
+/* copysignf() - S390 version.
+   Copyright (C) 2019 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/>.  */
+
+#if defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT
+# define NO_MATH_REDIRECT
+# include <math.h>
+# include <libm-alias-float.h>
+
+float
+__copysignf (float x, float y)
+{
+  __asm__ ("cpsdr %0,%1,%0" : "+f" (x) : "f" (y));
+  return x;
+}
+libm_alias_float (__copysign, copysign)
+
+#else
+# include <sysdeps/ieee754/flt-32/s_copysignf.c>
+#endif
diff --git a/sysdeps/s390/fpu/s_copysignl.c b/sysdeps/s390/fpu/s_copysignl.c
new file mode 100644
index 0000000000..b7aec86d90
--- /dev/null
+++ b/sysdeps/s390/fpu/s_copysignl.c
@@ -0,0 +1,41 @@ 
+/* copysignl() - S390 version.
+   Copyright (C) 2019 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/>.  */
+
+#if defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT
+# define NO_MATH_REDIRECT
+# include <math.h>
+# include <math_private.h>
+# include <math_ldbl_opt.h>
+# include <libm-alias-ldouble.h>
+
+_Float128
+__copysignl (_Float128 x, _Float128 y)
+{
+  __asm__ ("cpsdr %0,%1,%0" : "+f" (x) : "f" (y));
+  return x;
+}
+# if IS_IN (libc)
+long_double_symbol (libc, __copysignl, copysignl);
+# else
+libm_alias_ldouble (__copysign, copysign)
+# endif
+
+#else
+# include <sysdeps/ieee754/ldbl-64-128/s_copysignl.c>
+#endif