From patchwork Mon Nov 4 15:27:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 35618 Received: (qmail 51043 invoked by alias); 4 Nov 2019 15:28:04 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50909 invoked by uid 89); 4 Nov 2019 15:28:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=copysign X-HELO: mx0a-001b2d01.pphosted.com From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH 12/17] S390: Use copy-sign instruction for copysign functions. Date: Mon, 4 Nov 2019 16:27:19 +0100 In-Reply-To: <1572881244-6781-1-git-send-email-stli@linux.ibm.com> References: <1572881244-6781-1-git-send-email-stli@linux.ibm.com> x-cbid: 19110415-0016-0000-0000-000002C09A0D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19110415-0017-0000-0000-000033220BD5 Message-Id: <1572881244-6781-12-git-send-email-stli@linux.ibm.com> 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 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 + . */ + +#if defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT +# define NO_MATH_REDIRECT +# include +# include +# include + +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 +#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 + . */ + +#if defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT +# define NO_MATH_REDIRECT +# include +# include + +float +__copysignf (float x, float y) +{ + __asm__ ("cpsdr %0,%1,%0" : "+f" (x) : "f" (y)); + return x; +} +libm_alias_float (__copysign, copysign) + +#else +# include +#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 + . */ + +#if defined HAVE_S390_MIN_Z10_ZARCH_ASM_SUPPORT +# define NO_MATH_REDIRECT +# include +# include +# include +# include + +_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 +#endif