From patchwork Tue Feb 5 01:16:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul A. Clarke" X-Patchwork-Id: 31309 Received: (qmail 76233 invoked by alias); 5 Feb 2019 01:17:00 -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 76212 invoked by uid 89); 5 Feb 2019 01:16:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=Blanchard, blanchard, HContent-Transfer-Encoding:8bit X-HELO: mx0a-001b2d01.pphosted.com To: GNU C Library Cc: Tulio Magno Quites Machado Filho , Anton Blanchard From: Paul Clarke Subject: [PATCH] [powerpc] Use float in e_sqrt.c Date: Mon, 4 Feb 2019 19:16:50 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 x-cbid: 19020501-0052-0000-0000-000003833776 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010537; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000279; SDB=6.01156479; UDB=6.00603229; IPR=6.00936938; MB=3.00025439; MTD=3.00000008; XFM=3.00000015; UTC=2019-02-05 01:16:54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19020501-0053-0000-0000-00005FB898BB Message-Id: <8e1e3e59-26a6-b1cd-812e-b273b2c883ad@us.ibm.com> The type used within e_sqrt.c(__slow_ieee754_sqrtf) was, unnecessarily and likely inadvertently, double. float is not only appropriate, but also more efficient, avoiding the need for the compiler to emit a round-to-single-precision instruction. This is the difference in compiled code: 0000000000000000 <__ieee754_sqrtf>: 0: 2c 08 20 ec fsqrts f1,f1 - 4: 18 08 20 fc frsp f1,f1 - 8: 20 00 80 4e blr + 4: 20 00 80 4e blr (Found by Anton Blanchard.) 2019-02-04 Paul A. Clarke * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf): Use float instead of double. --- sysdeps/powerpc/fpu/e_sqrtf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/powerpc/fpu/e_sqrtf.c b/sysdeps/powerpc/fpu/e_sqrtf.c index 65df94b..5d9e900 100644 --- a/sysdeps/powerpc/fpu/e_sqrtf.c +++ b/sysdeps/powerpc/fpu/e_sqrtf.c @@ -138,7 +138,7 @@ __slow_ieee754_sqrtf (float x) float __ieee754_sqrtf (float x) { - double z; + float z; #ifdef _ARCH_PPCSQ asm ("fsqrts %0,%1\n" :"=f" (z):"f" (x));