[v3] Disable tests that require fesetround() on platforms without it
Commit Message
Some tests check for fenv and then proceed to use fesetround() directly,
but some platforms (at least RISC-V soft-float) have fenv but don't
support rounding modes. This adds a DG check that fesetround() actually
functions, which is then used by all the tests that call fesetround()
explicitly.
gcc/testsuite/ChangeLog
* lib/target-supports.exp
(check_effective_target_fenv_setround): New function.
* gcc.dg/torture/fp-double-convert-float-1.c: Check
fenv_fesetround.
* gcc.dg/torture/fp-int-convert-float128-timode-3.c: Likewise.
* 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.
* gcc.dg/torture/fp-uint64-convert-double-1.c: Likewise.
* gcc.dg/torture/fp-uint64-convert-double-2.c: Likewise.
gcc/ChangeLog
* doc/sourcebuild.texi: Document fenv_setround.
---
This was approved with the doc change in the v2
<9de73b8a-3f70-2f6b-e0d9-0fa4298c8823@gmail.com>, but I'll hold off a
bit on committing it just in case anyone else has feedback.
---
gcc/doc/sourcebuild.texi | 4 +++
.../torture/fp-double-convert-float-1.c | 2 +-
.../fp-int-convert-float128-timode-3.c | 2 +-
.../gcc.dg/torture/fp-int-convert-timode-2.c | 2 +-
.../gcc.dg/torture/fp-int-convert-timode-3.c | 2 +-
.../gcc.dg/torture/fp-int-convert-timode-4.c | 2 +-
.../torture/fp-uint64-convert-double-1.c | 2 +-
.../torture/fp-uint64-convert-double-2.c | 2 +-
gcc/testsuite/lib/target-supports.exp | 35 +++++++++++++++++++
9 files changed, 46 insertions(+), 7 deletions(-)
@@ -2560,6 +2560,10 @@ Target supports @file{fenv.h} with all the standard IEEE exceptions
and floating-point exceptions are raised by arithmetic operations for
decimal floating point.
+@item fenv_setround
+Target supports @file{fenv.h} and any standard IEEE rounding mode that is
+defined is implemented in the environment under test.
+
@item fileio
Target offers such file I/O library functions as @code{fopen},
@code{fclose}, @code{tmpnam}, and @code{remove}. This is a link-time
@@ -1,6 +1,6 @@
/* PR57245 */
/* { dg-do run } */
-/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target fenv_setround } */
/* { dg-additional-options "-frounding-math" } */
#include <fenv.h>
@@ -4,7 +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-require-effective-target fenv_setround } */
/* { dg-options "-frounding-math" } */
/* { dg-add-options __float128 } */
@@ -2,7 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
-/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target fenv_setround } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
@@ -2,7 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
-/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target fenv_setround } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
@@ -2,7 +2,7 @@
float. */
/* { dg-do run } */
/* { dg-require-effective-target int128 } */
-/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target fenv_setround } */
/* { dg-options "-frounding-math" } */
#include <fenv.h>
@@ -1,6 +1,6 @@
/* PR84407 */
/* { dg-do run } */
-/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target fenv_setround } */
/* { dg-additional-options "-frounding-math -fexcess-precision=standard" } */
#include <fenv.h>
@@ -1,6 +1,6 @@
/* PR84407 */
/* { dg-do run } */
-/* { dg-require-effective-target fenv } */
+/* { dg-require-effective-target fenv_setround } */
/* { dg-additional-options "-frounding-math" } */
#include <fenv.h>
@@ -10685,6 +10685,41 @@ proc check_effective_target_fenv_exceptions_dfp {} {
} [add_options_for_ieee "-std=gnu99"]]
}
+
+# Return 1 if <fenv.h> is availiable and supports fesetround.
+
+proc check_effective_target_fenv_setround {} {
+ return [check_runtime fenv_setround {
+ #include <fenv.h>
+ #include <stdlib.h>
+ int
+ main (void)
+ {
+ #ifdef FE_TONEAREST
+ if (fesetround (FE_TONEAREST) != 0)
+ abort ();
+ #endif
+
+ #ifdef FE_UPWARD
+ if (fesetround (FE_UPWARD) != 0)
+ abort ();
+ #endif
+
+ #ifdef FE_DOWNWARD
+ if (fesetround (FE_DOWNWARD) != 0)
+ abort ();
+ #endif
+
+ #ifdef FE_TOWARDZERO
+ if (fesetround (FE_TOWARDZERO) != 0)
+ abort ();
+ #endif
+
+ exit (0);
+ }
+ } [add_options_for_ieee "-std=gnu99"]]
+}
+
# Return 1 if -fexceptions is supported.
proc check_effective_target_exceptions {} {