[powerpc] Use float in e_sqrt.c

Message ID 8e1e3e59-26a6-b1cd-812e-b273b2c883ad@us.ibm.com
State New
Headers show
Series
  • [powerpc] Use float in e_sqrt.c
Related show

Commit Message

Paul A. Clarke Feb. 5, 2019, 1:16 a.m.
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  <pc@us.ibm.com>

	* 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(-)

Comments

Adhemerval Zanella Feb. 5, 2019, 1:11 p.m. | #1
On 04/02/2019 23:16, Paul Clarke wrote:
> 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  <pc@us.ibm.com>
> 
> 	* sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf):
> 	Use float instead of double.

LGTM, thanks.

> ---
>  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));
>
Gabriel F. T. Gomes Feb. 5, 2019, 2:29 p.m. | #2
On Mon, Feb 04 2019, Paul Clarke wrote:
> 
> 	* sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf):
> 	Use float instead of double.

Looks good to me.
Gabriel F. T. Gomes Feb. 11, 2019, 2:07 p.m. | #3
On Mon, Feb 04 2019, Paul Clarke wrote:
> 
> 	* sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf):
> 	Use float instead of double.

This patch is now committed.  Thanks.

Patch

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));