From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 43A583840C19 for ; Tue, 2 Mar 2021 01:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43A583840C19 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12214Pf7031243 for ; Mon, 1 Mar 2021 20:27:37 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3719b9be0f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 01 Mar 2021 20:27:37 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 1221MWnV030539 for ; Tue, 2 Mar 2021 01:27:36 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma02dal.us.ibm.com with ESMTP id 3710sqddtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 02 Mar 2021 01:27:36 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1221RZ5N15729002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Mar 2021 01:27:35 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD20EAC059; Tue, 2 Mar 2021 01:27:35 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F7BEAC05B; Tue, 2 Mar 2021 01:27:35 +0000 (GMT) Received: from li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com (unknown [9.85.138.189]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTPS; Tue, 2 Mar 2021 01:27:35 +0000 (GMT) Date: Mon, 1 Mar 2021 19:27:33 -0600 From: "Paul A. Clarke" To: Raphael Moreira Zinsly Cc: libc-alpha@sourceware.org, murphyp@linux.ibm.com, tuliom@linux.ibm.com Subject: Re: [PATCH v2 1/3] powerpc: Add optimized ilogb* for POWER9 Message-ID: <20210302012733.GD36821@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> References: <20210301175140.29109-1-rzinsly@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210301175140.29109-1-rzinsly@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-01_15:2021-03-01, 2021-03-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103020004 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 01:27:40 -0000 On Mon, Mar 01, 2021 at 02:51:38PM -0300, Raphael Moreira Zinsly via Libc-alpha wrote: > Changes since v1: > - Move the builtins definitions to powerpc's math_private.h. > - Check if the correct GCC version is used. > > --8<--- > > The instructions xsxexpdp and xsxexpqp introduced on POWER9 extract > the exponent from a double-precision and quad-precision floating-point > respectively, thus they can be used to improve ilogb, ilogbf and ilogbf128. > --- > sysdeps/powerpc/fpu/math_private.h | 20 +++++++++++- > .../powerpc64/le/fpu/w_ilogb_template.c | 31 +++++++++++++++++++ > 2 files changed, 50 insertions(+), 1 deletion(-) > create mode 100644 sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c > > diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h > index 91b1361749..accc28d091 100644 > --- a/sysdeps/powerpc/fpu/math_private.h > +++ b/sysdeps/powerpc/fpu/math_private.h > @@ -25,7 +25,23 @@ > > #include_next > > -#if defined _ARCH_PWR9 && __HAVE_DISTINCT_FLOAT128 > +#ifdef _ARCH_PWR9 > + > +#define __builtin_test_dc_ilogbf __builtin_test_dc_ilogb > +#define __builtin_ilogbf __builtin_ilogb > + > +#define __builtin_test_dc_ilogbl __builtin_test_dc_ilogbf128 > +#define __builtin_ilogbl __builtin_ilogbf128 > + > +#define __builtin_test_dc_ilogb(x, y) \ > + __builtin_vsx_scalar_test_data_class_dp(x, y) > +#define __builtin_ilogb(x) __builtin_vsx_scalar_extract_exp(x) - 0x3ff > + > +#define __builtin_test_dc_ilogbf128(x, y) \ > + __builtin_vsx_scalar_test_data_class_qp(x, y) > +#define __builtin_ilogbf128(x) __builtin_vsx_scalar_extract_expq(x) - 0x3fff > + > +#if __HAVE_DISTINCT_FLOAT128 > extern __always_inline _Float128 > __ieee754_sqrtf128 (_Float128 __x) > { > @@ -35,4 +51,6 @@ __ieee754_sqrtf128 (_Float128 __x) > } > #endif > > +#endif /* _ARCH_PWR9 */ > + > #endif /* _PPC_MATH_PRIVATE_H_ */ > diff --git a/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c > new file mode 100644 > index 0000000000..17ac7809e1 > --- /dev/null > +++ b/sysdeps/powerpc/powerpc64/le/fpu/w_ilogb_template.c > @@ -0,0 +1,31 @@ > +/* The builtins used are only available with GCC 8.0 or newer. */ > +#if defined _ARCH_PWR9 && __GNUC_PREREQ (8, 0) I wonder if it would be better to use __glibc_has_builtin () for the builtins on which you depend, rather than testing for a specific GCC level. (Same for patch 2/3.) PC > +#include > +#include > +#include > +#include > +#include > + > +int > +M_DECL_FUNC (__ilogb) (FLOAT x) > +{ > + int r; > + /* Check for exceptional cases. */ > + if (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f)) > + r = M_SUF (__builtin_ilogb) (x); > + else > + /* Fallback to the generic ilogb if x is NaN, Inf or subnormal. */ > + r = M_SUF (__ieee754_ilogb) (x); > + if (__builtin_expect (r == FP_ILOGB0, 0) > + || __builtin_expect (r == FP_ILOGBNAN, 0) > + || __builtin_expect (r == INT_MAX, 0)) > + { > + __set_errno (EDOM); > + __feraiseexcept (FE_INVALID); > + } > + return r; > +} > +declare_mgen_alias (__ilogb, ilogb) > +#else > +#include > +#endif > -- > 2.29.2 >