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: 1189005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106593-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="j60qrfAV"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 476Gt80c77z9sCJ for ; Tue, 5 Nov 2019 02:29:03 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:in-reply-to:references :message-id; q=dns; s=default; b=xF4EQjv9NGYe9Ic2eoWQGEyYstwK6Om dr/OW63kb0rLSONcCQlTrWEnxwAQslsLP1xYumhYUcQdQcPyUM3yiRO1xdppVI3P Nrw2kbEbIRXtvmztS0OmWVIgU32ewMi0V5rG5pNXx2UMbTbgp7xW/Cwv6T0iX09I NNhWjepmJXPk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:in-reply-to:references :message-id; s=default; bh=oMT15ijT6jq6pN5Ea9UxEn3fjgk=; b=j60qr fAVdUwVqYQwq4azX5xjPlPFuulWbk6OakcPoF7ms8jsD1qw/ExGWWBzexczP3Io6 QB3Pwjd8DiguxLagUu5vZBg6soNF0focRWwNhlRxxCf3lpMNHbMn5waCTPe2+N/0 0lGvhZ+ykzQzvZQnsOvz7vsnyaGtaRMvajsvNo= 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