Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
On Thu, 24 Jan 2019, Christophe Lyon wrote: > On Thu, 24 Jan 2019 at 15:31, Joseph Myers wrote: > > > > On Thu, 24 Jan 2019, Christophe Lyon wrote: > > > > > The attached small patch adds > > > /* { dg-require-effective-target fenv_exceptions } */ > > > to them. > > > > It should be a *new* effective-target, because these tests are nothing to > > do with exceptions; they're about rounding modes (but actually you only > > need an effective-target that tests whether fenv.h can be included because > > the tests contain #ifdef for the rounding modes used). > > > > OK, here is an updated version, including a doc for fenv_exceptions. OK. -- Joseph S. Myers jos...@codesourcery.com
Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
The test gcc.dg/torture/fp-int-convert-timode-3.c fails on darwin: the results are -0x1p+127 -0x1p+127 TIA Dominique
Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
On Thu, 24 Jan 2019 at 15:31, Joseph Myers wrote: > > On Thu, 24 Jan 2019, Christophe Lyon wrote: > > > The attached small patch adds > > /* { dg-require-effective-target fenv_exceptions } */ > > to them. > > It should be a *new* effective-target, because these tests are nothing to > do with exceptions; they're about rounding modes (but actually you only > need an effective-target that tests whether fenv.h can be included because > the tests contain #ifdef for the rounding modes used). > OK, here is an updated version, including a doc for fenv_exceptions. Christophe > -- > Joseph S. Myers > jos...@codesourcery.com diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 32a8f6a..a670456 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2128,6 +2128,13 @@ Target can truncate a file from a file descriptor, as used by @file{libgfortran/io/unix.c:fd_truncate}; i.e.@: @code{ftruncate} or @code{chsize}. +@item fenv +Target provides @file{fenv.h} include file. + +@item fenv_exceptions +Target supports @file{fenv.h} with all the standard IEEE exceptions +and floating-point exceptions are raised by arithmetic operations. + @item freestanding Target is @samp{freestanding} as defined in section 4 of the C99 standard. Effectively, it is a target which supports no extra headers or libraries diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c index fa6eb6b..c445d10 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode-3.c @@ -4,6 +4,7 @@ /* { dg-require-effective-target __float128 } */ /* { dg-require-effective-target base_quadfloat_support } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv } */ /* { dg-options "-frounding-math" } */ /* { dg-add-options __float128 } */ diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c index d6454fa..0c524a8 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c index dbfa481..a82f03d 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c index 63a305e..707d539 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c index e716109..09600f9 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index c0df467..92202ff 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -8536,6 +8536,14 @@ proc check_effective_target_avr_tiny { } { } } +# Return 1 if is available. + +proc check_effective_target_fenv {} { +return [check_no_compiler_messages fenv object { + #include +} [add_options_for_ieee "-std=gnu99"]] +} + # Return 1 if is available with all the standard IEEE # exceptions and floating-point exceptions are raised by arithmetic # operations. (If the target requires special options for "inexact" 2019-01-24 Christophe Lyon gcc/ * doc/sourcebuild.texi (Environment attributes): Add fenv and fenv_exceptions description. 2019-01-24 Christophe Lyon gcc/testsuite/ * lib/target-supports.exp (check_effective_target_fenv): New. * gcc.dg/torture/fp-int-convert-float128-timode-3.c: Add missing fenv effective target. * gcc.dg/torture/fp-int-convert-timode-1.c: Likewise. *
Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
On Thu, 24 Jan 2019, Christophe Lyon wrote: > The attached small patch adds > /* { dg-require-effective-target fenv_exceptions } */ > to them. It should be a *new* effective-target, because these tests are nothing to do with exceptions; they're about rounding modes (but actually you only need an effective-target that tests whether fenv.h can be included because the tests contain #ifdef for the rounding modes used). -- Joseph S. Myers jos...@codesourcery.com
Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
On Wed, 23 Jan 2019 at 22:14, H.J. Lu wrote: > > On Wed, Jan 23, 2019 at 12:50 PM Joseph Myers wrote: > > > > On Wed, 23 Jan 2019, H.J. Lu wrote: > > > > > + fesetround (FE_DOWNWARD); > > > + float fs = s128; > > > + if (fs != -0x1p+127) > > > +abort (); > > > + double ds = s128; > > > + if (ds != -0x1p+127) > > > +abort (); > > > > This definitely needs #ifdef FE_DOWNWARD; even just limited to glibc > > configurations, there are soft-float 64-bit configurations with no support > > for rounding modes other than to-nearest. Likewise for the other tests > > using rounding modes other than FE_TONEAREST. OK with that change. > > > > It's possible it will turn out a new effective-target is needed for fenv.h > > support, if there are still configurations people are testing with that > > lack fenv.h at all. > > > > This is the patch I am checking in. > Hi, The new tests fail to compile on aarch64-elf: fatal error: fenv.h: No such file or directory The attached small patch adds /* { dg-require-effective-target fenv_exceptions } */ to them. OK? Christophe > Thanks. > > -- > H.J. 2019-01-24 Christophe Lyon * gcc.dg/torture/fp-int-convert-timode-1.c: Add missing fenv_exceptions effective target. * gcc.dg/torture/fp-int-convert-timode-2.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-3.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-4.c: Likewise. diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c index d6454fa..8cadc1f 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv_exceptions } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c index dbfa481..ef97c1a 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv_exceptions } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c index 63a305e..63f68fc 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv_exceptions } */ /* { dg-options "-frounding-math" } */ #include diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c index e716109..acf1ce3 100644 --- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c @@ -2,6 +2,7 @@ float. */ /* { dg-do run } */ /* { dg-require-effective-target int128 } */ +/* { dg-require-effective-target fenv_exceptions } */ /* { dg-options "-frounding-math" } */ #include
Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
On Wed, Jan 23, 2019 at 12:50 PM Joseph Myers wrote: > > On Wed, 23 Jan 2019, H.J. Lu wrote: > > > + fesetround (FE_DOWNWARD); > > + float fs = s128; > > + if (fs != -0x1p+127) > > +abort (); > > + double ds = s128; > > + if (ds != -0x1p+127) > > +abort (); > > This definitely needs #ifdef FE_DOWNWARD; even just limited to glibc > configurations, there are soft-float 64-bit configurations with no support > for rounding modes other than to-nearest. Likewise for the other tests > using rounding modes other than FE_TONEAREST. OK with that change. > > It's possible it will turn out a new effective-target is needed for fenv.h > support, if there are still configurations people are testing with that > lack fenv.h at all. > This is the patch I am checking in. Thanks. -- H.J. From ecb5e6357cff988a6e34aed324f13b777af82deb Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 22 Jan 2019 18:55:35 -0800 Subject: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions FSTYPE FUNC (DWtype u) in libgcc2.c, which converts DI/TI to SF/DF, has /* No leading bits means u == minimum. */ if (count == 0) return -(Wtype_MAXp1_F * (Wtype_MAXp1_F / 2)); in the third case (where actually count == 0 only means the high part is minimum). It should be: /* No leading bits means u == minimum. */ if (count == 0) return Wtype_MAXp1_F * (FSTYPE) (hi | ((UWtype) u != 0)); instead. gcc/testsuite/ 2019-01-23 H.J. Lu PR libgcc/88931 * gcc.dg/torture/fp-int-convert-timode-1.c: New test. * gcc.dg/torture/fp-int-convert-timode-2.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-3.c: Likewise. * gcc.dg/torture/fp-int-convert-timode-4.c: Likewise. libgcc/ 2019-01-23 Joseph Myers PR libgcc/88931 * libgcc2.c (FSTYPE FUNC (DWtype u)): Correct no leading bits case. --- .../gcc.dg/torture/fp-int-convert-timode-1.c | 25 + .../gcc.dg/torture/fp-int-convert-timode-2.c | 27 +++ .../gcc.dg/torture/fp-int-convert-timode-3.c | 27 +++ .../gcc.dg/torture/fp-int-convert-timode-4.c | 27 +++ libgcc/libgcc2.c | 2 +- 5 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c create mode 100644 gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c new file mode 100644 index 000..d6454fada72 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-1.c @@ -0,0 +1,25 @@ +/* Test for correct rounding of conversions from __int128 to + float. */ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-frounding-math" } */ + +#include +#include + +int +main (void) +{ + volatile unsigned long long h = 0x8000LL; + volatile unsigned long long l = 0xdLL; + volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l; + volatile __int128 s128 = u128; + fesetround (FE_TONEAREST); + float fs = s128; + if (fs != -0x1p+127) +abort (); + double ds = s128; + if (ds != -0x1p+127) +abort (); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c new file mode 100644 index 000..dbfa481b4fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-2.c @@ -0,0 +1,27 @@ +/* Test for correct rounding of conversions from __int128 to + float. */ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-frounding-math" } */ + +#include +#include + +int +main (void) +{ +#ifdef FE_DOWNWARD + volatile unsigned long long h = 0x8000LL; + volatile unsigned long long l = 0xdLL; + volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l; + volatile __int128 s128 = u128; + fesetround (FE_DOWNWARD); + float fs = s128; + if (fs != -0x1p+127) +abort (); + double ds = s128; + if (ds != -0x1p+127) +abort (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c new file mode 100644 index 000..63a305ec3c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c @@ -0,0 +1,27 @@ +/* Test for correct rounding of conversions from __int128 to + float. */ +/* { dg-do run } */ +/* { dg-require-effective-target int128 } */ +/* { dg-options "-frounding-math" } */ + +#include +#include + +int +main (void) +{ +#ifdef FE_UPWARD + volatile unsigned long long h = 0x8000LL; + volatile unsigned long long l = 0xdLL; + volatile unsigned __int128 u128 = (((unsigned __int128) h) << 64) | l; + volatile __int128 s128
Re: [PATCH] libgcc2.c: Correct DI/TI -> SF/DF conversions
On Wed, 23 Jan 2019, H.J. Lu wrote: > + fesetround (FE_DOWNWARD); > + float fs = s128; > + if (fs != -0x1p+127) > +abort (); > + double ds = s128; > + if (ds != -0x1p+127) > +abort (); This definitely needs #ifdef FE_DOWNWARD; even just limited to glibc configurations, there are soft-float 64-bit configurations with no support for rounding modes other than to-nearest. Likewise for the other tests using rounding modes other than FE_TONEAREST. OK with that change. It's possible it will turn out a new effective-target is needed for fenv.h support, if there are still configurations people are testing with that lack fenv.h at all. -- Joseph S. Myers jos...@codesourcery.com