Use float in e_sqrt.c
authorPaul Clarke <pc@us.ibm.com>
Tue, 5 Feb 2019 01:16:50 +0000 (19:16 -0600)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Mon, 11 Feb 2019 14:03:23 +0000 (12:03 -0200)
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.)

ChangeLog
sysdeps/powerpc/fpu/e_sqrtf.c

index f12f435..6f1d967 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-11  Paul A. Clarke  <pc@us.ibm.com>
+
+       * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf):
+       Use float instead of double.
+
 2019-02-11  TAMUKI Shoichi  <tamuki@linet.gr.jp>
 
        * time/strftime_l.c: Fix a few whitespace arrangement inconsistencies.
index 65df94b..5d9e900 100644 (file)
@@ -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));