[1/2] s_sincosf.h: Change pio4 type to float [BZ #28713]

Message ID 20211220231817.4051571-1-hjl.tools@gmail.com
State Committed
Headers
Series [1/2] s_sincosf.h: Change pio4 type to float [BZ #28713] |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

H.J. Lu Dec. 20, 2021, 11:18 p.m. UTC
  s_cosf.c and s_sinf.c have

  if (abstop12 (y) < abstop12 (pio4))

where abstop12 takes a float argument, but pio4 is static const double.
pio4 is used only in calls to abstop12 and never in arithmetic.  Change
it to float to fix:

FAIL: math/test-float-cos
FAIL: math/test-float-sin
FAIL: math/test-float-sincos
FAIL: math/test-float32-cos
FAIL: math/test-float32-sin
FAIL: math/test-float32-sincos

when compiling with GCC 12.
---
 sysdeps/ieee754/flt-32/s_sincosf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Paul Zimmermann Dec. 21, 2021, 8:52 a.m. UTC | #1
Dear H.J.,

I confirm the 6 failures with gcc12, and that they are fixed by that patch.

I suggest one small change: replace pio4 = 0x1.921FB54442D18p-1 by
pio4 = 0x1.921fb6p-1f, where 0x1.921fb6p-1 is pi/4 rounded to nearest
in binary32, and the 'f' suffix denotes a float constant.

LGTM with that small change.

Paul

> Date: Mon, 20 Dec 2021 15:18:16 -0800
> From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
> Cc: Joseph Myers <joseph@codesourcery.com>
> 
> s_cosf.c and s_sinf.c have
> 
>   if (abstop12 (y) < abstop12 (pio4))
> 
> where abstop12 takes a float argument, but pio4 is static const double.
> pio4 is used only in calls to abstop12 and never in arithmetic.  Change
> it to float to fix:
> 
> FAIL: math/test-float-cos
> FAIL: math/test-float-sin
> FAIL: math/test-float-sincos
> FAIL: math/test-float32-cos
> FAIL: math/test-float32-sin
> FAIL: math/test-float32-sincos
> 
> when compiling with GCC 12.
> ---
>  sysdeps/ieee754/flt-32/s_sincosf.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/ieee754/flt-32/s_sincosf.h b/sysdeps/ieee754/flt-32/s_sincosf.h
> index 125ab7f846..0dadd6374e 100644
> --- a/sysdeps/ieee754/flt-32/s_sincosf.h
> +++ b/sysdeps/ieee754/flt-32/s_sincosf.h
> @@ -24,7 +24,7 @@
>  /* 2PI * 2^-64.  */
>  static const double pi63 = 0x1.921FB54442D18p-62;
>  /* PI / 4.  */
> -static const double pio4 = 0x1.921FB54442D18p-1;
> +static const float pio4 = 0x1.921FB54442D18p-1;
>  
>  /* Polynomial data (the cosine polynomial is negated in the 2nd entry).  */
>  extern const sincos_t __sincosf_table[2] attribute_hidden;
> -- 
> 2.33.1
> 
>
  
H.J. Lu Dec. 21, 2021, 4:58 p.m. UTC | #2
On Tue, Dec 21, 2021 at 12:52 AM Paul Zimmermann
<Paul.Zimmermann@inria.fr> wrote:
>
>        Dear H.J.,
>
> I confirm the 6 failures with gcc12, and that they are fixed by that patch.
>
> I suggest one small change: replace pio4 = 0x1.921FB54442D18p-1 by
> pio4 = 0x1.921fb6p-1f, where 0x1.921fb6p-1 is pi/4 rounded to nearest
> in binary32, and the 'f' suffix denotes a float constant.
>
> LGTM with that small change.

This is the patch I am checking in with

-static const double pio4 = 0x1.921FB54442D18p-1;
+static const float pio4 = 0x1.921FB6p-1f;

Thanks.

> Paul
>
> > Date: Mon, 20 Dec 2021 15:18:16 -0800
> > From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
> > Cc: Joseph Myers <joseph@codesourcery.com>
> >
> > s_cosf.c and s_sinf.c have
> >
> >   if (abstop12 (y) < abstop12 (pio4))
> >
> > where abstop12 takes a float argument, but pio4 is static const double.
> > pio4 is used only in calls to abstop12 and never in arithmetic.  Change
> > it to float to fix:
> >
> > FAIL: math/test-float-cos
> > FAIL: math/test-float-sin
> > FAIL: math/test-float-sincos
> > FAIL: math/test-float32-cos
> > FAIL: math/test-float32-sin
> > FAIL: math/test-float32-sincos
> >
> > when compiling with GCC 12.
> > ---
> >  sysdeps/ieee754/flt-32/s_sincosf.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/sysdeps/ieee754/flt-32/s_sincosf.h b/sysdeps/ieee754/flt-32/s_sincosf.h
> > index 125ab7f846..0dadd6374e 100644
> > --- a/sysdeps/ieee754/flt-32/s_sincosf.h
> > +++ b/sysdeps/ieee754/flt-32/s_sincosf.h
> > @@ -24,7 +24,7 @@
> >  /* 2PI * 2^-64.  */
> >  static const double pi63 = 0x1.921FB54442D18p-62;
> >  /* PI / 4.  */
> > -static const double pio4 = 0x1.921FB54442D18p-1;
> > +static const float pio4 = 0x1.921FB54442D18p-1;
> >
> >  /* Polynomial data (the cosine polynomial is negated in the 2nd entry).  */
> >  extern const sincos_t __sincosf_table[2] attribute_hidden;
> > --
> > 2.33.1
> >
> >
  

Patch

diff --git a/sysdeps/ieee754/flt-32/s_sincosf.h b/sysdeps/ieee754/flt-32/s_sincosf.h
index 125ab7f846..0dadd6374e 100644
--- a/sysdeps/ieee754/flt-32/s_sincosf.h
+++ b/sysdeps/ieee754/flt-32/s_sincosf.h
@@ -24,7 +24,7 @@ 
 /* 2PI * 2^-64.  */
 static const double pi63 = 0x1.921FB54442D18p-62;
 /* PI / 4.  */
-static const double pio4 = 0x1.921FB54442D18p-1;
+static const float pio4 = 0x1.921FB54442D18p-1;
 
 /* Polynomial data (the cosine polynomial is negated in the 2nd entry).  */
 extern const sincos_t __sincosf_table[2] attribute_hidden;