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 439E339730E6 for ; Wed, 3 Mar 2021 17:20:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 439E339730E6 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 123H4DhD114238 for ; Wed, 3 Mar 2021 12:20:09 -0500 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 372d4tv0av-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Mar 2021 12:20:09 -0500 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 123HHQUL006429 for ; Wed, 3 Mar 2021 17:20:08 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma01wdc.us.ibm.com with ESMTP id 36ydq98g8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 03 Mar 2021 17:20:08 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 123HK70r8324028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 3 Mar 2021 17:20:07 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9733AE062; Wed, 3 Mar 2021 17:20:07 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D856AE060; Wed, 3 Mar 2021 17:20:07 +0000 (GMT) Received: from li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com (unknown [9.80.206.228]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTPS; Wed, 3 Mar 2021 17:20:07 +0000 (GMT) Date: Wed, 3 Mar 2021 11:20:05 -0600 From: "Paul A. Clarke" To: Raphael M Zinsly Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2 1/3] powerpc: Add optimized ilogb* for POWER9 Message-ID: <20210303172005.GB16878@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> References: <20210301175140.29109-1-rzinsly@linux.ibm.com> <20210302012733.GD36821@li-24c3614c-2adc-11b2-a85c-85f334518bdb.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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-03_05:2021-03-03, 2021-03-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 suspectscore=0 spamscore=0 clxscore=1015 malwarescore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103030123 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: Wed, 03 Mar 2021 17:20:11 -0000 On Wed, Mar 03, 2021 at 01:23:43PM -0300, Raphael M Zinsly via Libc-alpha wrote: > On 01/03/2021 22:27, Paul A. Clarke wrote: > > 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. > > > > I didn't find a __glibc_has_builtin definition, do you mean the > preprocessor's __has_builtin()? I believe it's not available on GCC 8.0. misc/sys/cdefs.h: -- /* Compilers that lack __has_attribute may object to #if defined __has_attribute && __has_attribute (...) even though they do not need to evaluate the right-hand side of the &&. Similarly for __has_builtin, etc. */ [...] #ifdef __has_builtin # define __glibc_has_builtin(name) __has_builtin (name) #else # define __glibc_has_builtin(name) 0 #endif -- ... so, it covers pre-GCC8 by always saying "nope". PC