[v2] 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.
---
Changes since v1 <20220428155514.27063-1-palmer@rivosinc.com>:
* Checks all defined IEEE rounding modes, rather than just using "1"
(which isn't itself a valid mode on all systems). The original goal
was to avoid depending on the macros being defined in the first
place, but after thinking about it this seems better anyway as IIUC
users are supposed to be testing for those before using them already
(the trick here is that RISC-V may choose not to implement these at
runtime, even when they are defined).
* Those atomics were a known issue, not sure how I forgot about them.
---
.../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 +++++++++++++++++++
8 files changed, 42 insertions(+), 7 deletions(-)
Comments
On 4/29/2022 5:44 PM, Palmer Dabbelt wrote:
> 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.
I think the new effective target check needs to be documented in
doc/sourcebuild.texi. With that change, this is OK.
jeff
On Tue, 03 May 2022 08:21:45 PDT (-0700), gcc-patches@gcc.gnu.org wrote:
>
>
> On 4/29/2022 5:44 PM, Palmer Dabbelt wrote:
>> 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.
> I think the new effective target check needs to be documented in
> doc/sourcebuild.texi. With that change, this is OK.
Thanks, I sent a v3 and will commit it unless someone points out an
issue.
@@ -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 {} {