public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] Disable tests that require fesetround() on platforms without it
@ 2022-04-29 23:44 Palmer Dabbelt
  2022-05-03 15:21 ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Palmer Dabbelt @ 2022-04-29 23:44 UTC (permalink / raw)
  To: Kito Cheng, gcc-patches, joseph

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

diff --git a/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c b/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c
index ec23274ea98..656e5c345e7 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-double-convert-float-1.c
@@ -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>
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 c445d10522e..499e8c0cabf 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,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 } */
 
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 a82f03d079c..3f91f8f3833 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,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>
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 707d539335f..816fcb1120e 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,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>
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 09600f90903..6337a6d3f1e 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,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>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c
index fadad8c3198..43aeb81a602 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-1.c
@@ -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>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c
index 952f96b33c9..d380b4a80e8 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-uint64-convert-double-2.c
@@ -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>
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 2d5d0539bb4..bd4dab0a9ad 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -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 {} {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Disable tests that require fesetround() on platforms without it
  2022-04-29 23:44 [PATCH v2] Disable tests that require fesetround() on platforms without it Palmer Dabbelt
@ 2022-05-03 15:21 ` Jeff Law
  2022-05-13 17:28   ` Palmer Dabbelt
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2022-05-03 15:21 UTC (permalink / raw)
  To: gcc-patches



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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Disable tests that require fesetround() on platforms without it
  2022-05-03 15:21 ` Jeff Law
@ 2022-05-13 17:28   ` Palmer Dabbelt
  0 siblings, 0 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2022-05-13 17:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: gcc-patches

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-13 17:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 23:44 [PATCH v2] Disable tests that require fesetround() on platforms without it Palmer Dabbelt
2022-05-03 15:21 ` Jeff Law
2022-05-13 17:28   ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).