public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
@ 2023-08-20 19:37 FX Coudert
  2023-08-21 19:12 ` Tobias Burnus
  0 siblings, 1 reply; 11+ messages in thread
From: FX Coudert @ 2023-08-20 19:37 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, tobias

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

Hi,

testsuite/libgomp.c/simd-math-1.c calls nonstandard functions that are not available on darwin (and possibly other systems?). Because I did not want to disable their testing completely, I suggest we simply use preprocessor macros to avoid them on darwin.

This fixes the test failure on aarch64-apple-darwin.
OK to commit?

FX


[-- Attachment #2: 0001-libgomp-testsuite-Do-not-call-nonstandard-functions-.patch --]
[-- Type: application/octet-stream, Size: 2740 bytes --]

From bc7f4862b9301c9490c7e80a58aa21c7a9727bcd Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gmail.com>
Date: Sun, 20 Aug 2023 21:32:18 +0200
Subject: [PATCH] libgomp, testsuite: Do not call nonstandard functions on
 darwin

The following functions are not standard, and not always available on
darwin. They should not be called there: gamma, gammaf, scalb, scalbf,
significand, and significandf.

libgomp/ChangeLog:

	* testsuite/libgomp.c/simd-math-1.c: Avoid calling nonstandard
	functions on darwin.
---
 libgomp/testsuite/libgomp.c/simd-math-1.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libgomp/testsuite/libgomp.c/simd-math-1.c b/libgomp/testsuite/libgomp.c/simd-math-1.c
index dd2077cc597..b6127c118d1 100644
--- a/libgomp/testsuite/libgomp.c/simd-math-1.c
+++ b/libgomp/testsuite/libgomp.c/simd-math-1.c
@@ -160,7 +160,9 @@ int main (void)
   TEST_FUN (float, -10.0, 10.0, expf);
   TEST_FUN (float, -10.0, 10.0, exp2f);
   TEST_FUN2 (float, -10.0, 10.0, 100.0, -25.0, fmodf);
+#if !defined(__APPLE__)
   TEST_FUN (float, -10.0, 10.0, gammaf);
+#endif
   TEST_FUN2 (float, -10.0, 10.0, 15.0, -5.0,hypotf);
   TEST_FUN (float, -10.0, 10.0, lgammaf);
   TEST_FUN (float, -1.0, 50.0, logf);
@@ -169,8 +171,10 @@ int main (void)
   TEST_FUN2 (float, -100.0, 100.0, 100.0, -100.0, powf);
   TEST_FUN2 (float, -50.0, 100.0, -2.0, 40.0, remainderf);
   TEST_FUN (float, -50.0, 50.0, rintf);
+#if !defined(__APPLE__)
   TEST_FUN2 (float, -50.0, 50.0, -10.0, 32.0, __builtin_scalbf);
   TEST_FUN (float, -10.0, 10.0, __builtin_significandf);
+#endif
   TEST_FUN (float, -3.14159265359, 3.14159265359, sinf);
   TEST_FUN (float, -3.14159265359, 3.14159265359, sinhf);
   TEST_FUN (float, -0.1, 10000.0, sqrtf);
@@ -193,7 +197,9 @@ int main (void)
   TEST_FUN (double, -10.0, 10.0, exp);
   TEST_FUN (double, -10.0, 10.0, exp2);
   TEST_FUN2 (double, -10.0, 10.0, 100.0, -25.0, fmod);
+#if !defined(__APPLE__)
   TEST_FUN (double, -10.0, 10.0, gamma);
+#endif
   TEST_FUN2 (double, -10.0, 10.0, 15.0, -5.0, hypot);
   TEST_FUN (double, -10.0, 10.0, lgamma);
   TEST_FUN (double, -1.0, 50.0, log);
@@ -202,8 +208,10 @@ int main (void)
   TEST_FUN2 (double, -100.0, 100.0, 100.0, -100.0, pow);
   TEST_FUN2 (double, -50.0, 100.0, -2.0, 40.0, remainder);
   TEST_FUN (double, -50.0, 50.0, rint);
+#if !defined(__APPLE__)
   TEST_FUN2 (double, -50.0, 50.0, -10.0, 32.0, __builtin_scalb);
   TEST_FUN (double, -10.0, 10.0, __builtin_significand);
+#endif
   TEST_FUN (double, -3.14159265359, 3.14159265359, sin);
   TEST_FUN (double, -3.14159265359, 3.14159265359, sinh);
   TEST_FUN (double, -0.1, 10000.0, sqrt);
-- 
2.39.2 (Apple Git-143)


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-20 19:37 [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin FX Coudert
@ 2023-08-21 19:12 ` Tobias Burnus
  2023-08-21 19:41   ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: Tobias Burnus @ 2023-08-21 19:12 UTC (permalink / raw)
  To: FX Coudert, GCC Patches; +Cc: Jakub Jelinek

Hi FX,
On 20.08.23 21:37, FX Coudert wrote:
> testsuite/libgomp.c/simd-math-1.c calls nonstandard functions that are not available on darwin (and possibly other systems?).

Namely:

* "gamma" which has been repaced by tgamma and lgamma as BSD's gamma ==
tgamma while glibc's gamma == lgamma.

* __builtin_scalb{,f,l} – where "scalb" (only double version) was in
POSIX.1-2001 but was replaced in favour of scalb{l,}n{,f,l} which take
an int/long instead of a floating point number for the exponent argument
(2nd arg).

* __builtin_significand{,f,l} – where the man page states: "This
function exists mainly for use in certain standardized tests for IEEE
754 conformance." and "These functions are nonstandard; the double
version is available on a number of other systems."

(BTW: The testcase does not test the long-double versions – which makes
sense as it evolved as nvptx/gcn SIMD test.)

* * *

Looking at the testcase, I wonder:

(a) why there is no test for scalb[l,}n{,f,l} (= scalb* but with int or
long as second argument for 'exp'). (Requires a new macro taking a
second type.)

(b) whether the tgamma test shouldn't be only TEST_FUN_XFAIL for '#if
defined(__AMDGCN__) || defined(__nvptx__)' and TEST_FUN otherwise. Other
platforms could then still add themselves to XFAIL as needed.

> Because I did not want to disable their testing completely, I suggest we simply use preprocessor macros to avoid them on darwin.
That makes sense.
> This fixes the test failure on aarch64-apple-darwin.
> OK to commit?

OK. — I'd prefer if you also changed + tested a fix for my (a) + (b)
remarks, but as those are unrelated, I understand if you don't and just
commit your Darwin patch.

Thanks,

Tobias

>  From bc7f4862b9301c9490c7e80a58aa21c7a9727bcd Mon Sep 17 00:00:00 2001
> From: Francois-Xavier Coudert<fxcoudert@gmail.com>
> Date: Sun, 20 Aug 2023 21:32:18 +0200
> Subject: [PATCH] libgomp, testsuite: Do not call nonstandard functions on
>   darwin
>
> The following functions are not standard, and not always available on
> darwin. They should not be called there: gamma, gammaf, scalb, scalbf,
> significand, and significandf.
>
> libgomp/ChangeLog:
>
>       * testsuite/libgomp.c/simd-math-1.c: Avoid calling nonstandard
>       functions on darwin.
> ---
>   libgomp/testsuite/libgomp.c/simd-math-1.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/libgomp/testsuite/libgomp.c/simd-math-1.c b/libgomp/testsuite/libgomp.c/simd-math-1.c
> index dd2077cc597..b6127c118d1 100644
> --- a/libgomp/testsuite/libgomp.c/simd-math-1.c
> +++ b/libgomp/testsuite/libgomp.c/simd-math-1.c
> @@ -160,7 +160,9 @@ int main (void)
>     TEST_FUN (float, -10.0, 10.0, expf);
>     TEST_FUN (float, -10.0, 10.0, exp2f);
>     TEST_FUN2 (float, -10.0, 10.0, 100.0, -25.0, fmodf);
> +#if !defined(__APPLE__)
>     TEST_FUN (float, -10.0, 10.0, gammaf);
> +#endif
>     TEST_FUN2 (float, -10.0, 10.0, 15.0, -5.0,hypotf);
>     TEST_FUN (float, -10.0, 10.0, lgammaf);
>     TEST_FUN (float, -1.0, 50.0, logf);
> @@ -169,8 +171,10 @@ int main (void)
>     TEST_FUN2 (float, -100.0, 100.0, 100.0, -100.0, powf);
>     TEST_FUN2 (float, -50.0, 100.0, -2.0, 40.0, remainderf);
>     TEST_FUN (float, -50.0, 50.0, rintf);
> +#if !defined(__APPLE__)
>     TEST_FUN2 (float, -50.0, 50.0, -10.0, 32.0, __builtin_scalbf);
>     TEST_FUN (float, -10.0, 10.0, __builtin_significandf);
> +#endif
>     TEST_FUN (float, -3.14159265359, 3.14159265359, sinf);
>     TEST_FUN (float, -3.14159265359, 3.14159265359, sinhf);
>     TEST_FUN (float, -0.1, 10000.0, sqrtf);
> @@ -193,7 +197,9 @@ int main (void)
>     TEST_FUN (double, -10.0, 10.0, exp);
>     TEST_FUN (double, -10.0, 10.0, exp2);
>     TEST_FUN2 (double, -10.0, 10.0, 100.0, -25.0, fmod);
> +#if !defined(__APPLE__)
>     TEST_FUN (double, -10.0, 10.0, gamma);
> +#endif
>     TEST_FUN2 (double, -10.0, 10.0, 15.0, -5.0, hypot);
>     TEST_FUN (double, -10.0, 10.0, lgamma);
>     TEST_FUN (double, -1.0, 50.0, log);
> @@ -202,8 +208,10 @@ int main (void)
>     TEST_FUN2 (double, -100.0, 100.0, 100.0, -100.0, pow);
>     TEST_FUN2 (double, -50.0, 100.0, -2.0, 40.0, remainder);
>     TEST_FUN (double, -50.0, 50.0, rint);
> +#if !defined(__APPLE__)
>     TEST_FUN2 (double, -50.0, 50.0, -10.0, 32.0, __builtin_scalb);
>     TEST_FUN (double, -10.0, 10.0, __builtin_significand);
> +#endif
>     TEST_FUN (double, -3.14159265359, 3.14159265359, sin);
>     TEST_FUN (double, -3.14159265359, 3.14159265359, sinh);
>     TEST_FUN (double, -0.1, 10000.0, sqrt);
> -- 2.39.2 (Apple Git-143)
> Attachments:
>
> 0001-libgomp-testsuite-Do-not-call-nonstandard-functions-.patch       2,6 KB
>
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-21 19:12 ` Tobias Burnus
@ 2023-08-21 19:41   ` Jakub Jelinek
  2023-08-21 19:50     ` FX Coudert
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2023-08-21 19:41 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: FX Coudert, GCC Patches

On Mon, Aug 21, 2023 at 09:12:09PM +0200, Tobias Burnus wrote:
> OK. — I'd prefer if you also changed + tested a fix for my (a) + (b)
> remarks, but as those are unrelated, I understand if you don't and just
> commit your Darwin patch.

I don't like the #if !defined(__APPLE__) conditionals everywhere in the
test, I think much cleaner would be to add an effective target to test
for those functions (ideally that calls to all of them link;
all of them at once) and then use
{ dg-additional-options "-DWHATEVER" { target whatever } }
and use #ifdef WHATEVER conditionals instead.
That way any other target which doesn't have all these will not suffer from
it.

	Jakub


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-21 19:41   ` Jakub Jelinek
@ 2023-08-21 19:50     ` FX Coudert
  2023-08-21 19:55       ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: FX Coudert @ 2023-08-21 19:50 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Tobias Burnus, GCC Patches

> I don't like the #if !defined(__APPLE__) conditionals everywhere in the
> test, I think much cleaner would be to add an effective target to test
> for those functions

I understand, I wanted to not just report the issue but propose an option. It seems a bit heavy to design an effective target just for one test, though, no?

Another possibility would be to replace #if !defined(__APPLE__) by #if defined(__linux__), or glibc?

FX



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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-21 19:50     ` FX Coudert
@ 2023-08-21 19:55       ` Jakub Jelinek
  2023-08-21 20:00         ` FX Coudert
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2023-08-21 19:55 UTC (permalink / raw)
  To: FX Coudert; +Cc: Tobias Burnus, GCC Patches

On Mon, Aug 21, 2023 at 09:50:37PM +0200, FX Coudert wrote:
> > I don't like the #if !defined(__APPLE__) conditionals everywhere in the
> > test, I think much cleaner would be to add an effective target to test
> > for those functions
> 
> I understand, I wanted to not just report the issue but propose an option. It seems a bit heavy to design an effective target just for one test, though, no?

It has the advantage of getting it right on all current and future targets.

> Another possibility would be to replace #if !defined(__APPLE__) by #if defined(__linux__), or glibc?

If we do it, I'd still prefer one specific macro for all those spots,
TEST_NONSTANDARD_MATH_FNS or whatever and then at the start of the test
you can do either
#if !defined(__APPLE__) or #if defined(__linux__) or whatever else around
its definition.
That has the advantage of only touching one spot if one wants to add or
remove those on some other target.

	Jakub


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-21 19:55       ` Jakub Jelinek
@ 2023-08-21 20:00         ` FX Coudert
  2023-08-21 20:11           ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: FX Coudert @ 2023-08-21 20:00 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Tobias Burnus, GCC Patches

>> I understand, I wanted to not just report the issue but propose an option. It seems a bit heavy to design an effective target just for one test, though, no?
> 
> It has the advantage of getting it right on all current and future targets.

Something like this? (not tested yet)


diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 2f9e538278f..85d467434e9 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -377,6 +377,24 @@ proc offload_target_to_openacc_device_type { offload_target } {
     }
 }
  +# Return 1 if certain nonstandard math functions are available
+# on the target.
+proc libgomp_check_effective_target_nonstandard_math_functions { } {
+    return [check_no_compiler_messages nonstandard_math_functions executable {
+#include <math.h>
+int main() {
+  float x = 42;
+  double y = 42;
+  x = gammaf (x);
+  x = __builtin_scalbf (x, 2.f);
+  x =__builtin_significandf (x);
+  y = gamma (y);
+  y = __builtin_scalb (y, 2.);
+  y =__builtin_significand (y);
+  return 0;
+} } "-lm" ]
+}
+
 # Return 1 if compiling for the specified offload target
 # Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES=
 # in the -v compiler output.


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-21 20:00         ` FX Coudert
@ 2023-08-21 20:11           ` Jakub Jelinek
  2023-08-22  8:16             ` FX Coudert
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2023-08-21 20:11 UTC (permalink / raw)
  To: FX Coudert; +Cc: Tobias Burnus, GCC Patches

On Mon, Aug 21, 2023 at 10:00:30PM +0200, FX Coudert wrote:
> >> I understand, I wanted to not just report the issue but propose an option. It seems a bit heavy to design an effective target just for one test, though, no?
> > 
> > It has the advantage of getting it right on all current and future targets.
> 
> Something like this? (not tested yet)

Yes (of course if it works on linux and is true there and on darwin and
expectedly is false there).

> --- a/libgomp/testsuite/lib/libgomp.exp
> +++ b/libgomp/testsuite/lib/libgomp.exp
> @@ -377,6 +377,24 @@ proc offload_target_to_openacc_device_type { offload_target } {
>      }
>  }
>   +# Return 1 if certain nonstandard math functions are available
> +# on the target.
> +proc libgomp_check_effective_target_nonstandard_math_functions { } {
> +    return [check_no_compiler_messages nonstandard_math_functions executable {
> +#include <math.h>
> +int main() {
> +  float x = 42;
> +  double y = 42;
> +  x = gammaf (x);
> +  x = __builtin_scalbf (x, 2.f);
> +  x =__builtin_significandf (x);
> +  y = gamma (y);
> +  y = __builtin_scalb (y, 2.);
> +  y =__builtin_significand (y);
> +  return 0;
> +} } "-lm" ]
> +}
> +
>  # Return 1 if compiling for the specified offload target
>  # Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES=
>  # in the -v compiler output.

	Jakub


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-21 20:11           ` Jakub Jelinek
@ 2023-08-22  8:16             ` FX Coudert
  2023-08-22  8:23               ` Jakub Jelinek
  2023-08-22  8:25               ` FX Coudert
  0 siblings, 2 replies; 11+ messages in thread
From: FX Coudert @ 2023-08-22  8:16 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Tobias Burnus, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 134 bytes --]

Revised patch. I does the job on darwin, can you check that it still tests the functions on Linux?
And if so, OK to commit?

FX


[-- Attachment #2: 0001-Testsuite-DWARF2-adjust-regexp-to-match-darwin-outpu.patch --]
[-- Type: application/octet-stream, Size: 1402 bytes --]

From f5b8d46bb89ee7664731e611d937ddbbf58d9f6b Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gmail.com>
Date: Sun, 20 Aug 2023 12:53:19 +0200
Subject: [PATCH] Testsuite, DWARF2: adjust regexp to match darwin output

gcc/testsuite/ChangeLog:

	* gcc.dg/debug/dwarf2/inline4.c: Ajdust regexp to match darwin
	output.
---
 gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
index 2faef6e2a4f..22eb35fcf09 100644
--- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline4.c
@@ -2,7 +2,7 @@
    the DW_TAG_inlined_subroutine and the DW_TAG_variable for the local.  */
 /* { dg-options "-O -gdwarf -dA" } */
 /* { dg-do compile } */
-/* { dg-final { scan-assembler "DW_TAG_inlined_subroutine\[^\\(\]*\\(\[^\\)\]*\\)\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) DW_TAG_variable" } } */
+/* { dg-final { scan-assembler "DW_TAG_inlined_subroutine\[^\\(\]*\(\|\\(\[^\\)\]*\\)\)\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) DW_TAG_formal_parameter\[^\\(\]*\\(DIE \\(0x\[0-9a-f\]*\\) DW_TAG_variable" } } */
 /* { dg-final { scan-assembler-times "DW_TAG_inlined_subroutine" 2 } } */
 
 static int foo (int i)
-- 
2.39.2 (Apple Git-143)


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-22  8:16             ` FX Coudert
@ 2023-08-22  8:23               ` Jakub Jelinek
  2023-08-22  8:25               ` FX Coudert
  1 sibling, 0 replies; 11+ messages in thread
From: Jakub Jelinek @ 2023-08-22  8:23 UTC (permalink / raw)
  To: FX Coudert; +Cc: Tobias Burnus, GCC Patches

On Tue, Aug 22, 2023 at 10:16:37AM +0200, FX Coudert wrote:
> Revised patch. I does the job on darwin, can you check that it still tests the functions on Linux?

Seems the attached patch doesn't match what was discussed in this thread.
And for that DWARF patch, I'd like to see what different output
you get on Darwin...

> And if so, OK to commit?

	Jakub


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-22  8:16             ` FX Coudert
  2023-08-22  8:23               ` Jakub Jelinek
@ 2023-08-22  8:25               ` FX Coudert
  2023-08-22 17:10                 ` Jakub Jelinek
  1 sibling, 1 reply; 11+ messages in thread
From: FX Coudert @ 2023-08-22  8:25 UTC (permalink / raw)
  To: François-Xavier Coudert; +Cc: Jakub Jelinek, Tobias Burnus, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

> Revised patch. I does the job on darwin, can you check that it still tests the functions on Linux?
> And if so, OK to commit?

With the correct file, sorry.


[-- Attachment #2: 0001-libgomp-testsuite-Do-not-call-nonstandard-functions.patch --]
[-- Type: application/octet-stream, Size: 4250 bytes --]

From 918e27389189e7bdad7066b246ae890bfe20ca4f Mon Sep 17 00:00:00 2001
From: Francois-Xavier Coudert <fxcoudert@gmail.com>
Date: Tue, 22 Aug 2023 10:15:00 +0200
Subject: [PATCH] libgomp, testsuite: Do not call nonstandard functions

The following functions are not standard, and not always available
(e.g., on darwin). They should not be called unless available: gamma,
gammaf, scalb, scalbf, significand, and significandf.

libgomp/ChangeLog:

	* testsuite/libgomp.c/simd-math-1.c: Avoid calling nonstandard
	functions.
---
 libgomp/testsuite/lib/libgomp.exp         | 19 +++++++++++++++++++
 libgomp/testsuite/libgomp.c/simd-math-1.c |  9 +++++++++
 2 files changed, 28 insertions(+)

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 2f9e538278f..a143b5d0def 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -377,6 +377,25 @@ proc offload_target_to_openacc_device_type { offload_target } {
     }
 }
 
+# Return 1 if certain nonstandard math functions are available
+# on the target: gamma, scalb, significand, and their float variants.
+proc check_effective_target_nonstandard_math_functions { } {
+    return [check_no_compiler_messages nonstandard_math_functions executable {
+      #include <math.h>
+      int main() {
+        float x = 42;
+        double y = 42;
+        x = gammaf (x);
+        x = __builtin_scalbf (x, 2.f);
+        x =__builtin_significandf (x);
+        y = gamma (y);
+        y = __builtin_scalb (y, 2.);
+        y =__builtin_significand (y);
+        return 0;
+      }
+    } "-lm" ]
+}
+
 # Return 1 if compiling for the specified offload target
 # Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES=
 # in the -v compiler output.
diff --git a/libgomp/testsuite/libgomp.c/simd-math-1.c b/libgomp/testsuite/libgomp.c/simd-math-1.c
index dd2077cc597..42a008c80fc 100644
--- a/libgomp/testsuite/libgomp.c/simd-math-1.c
+++ b/libgomp/testsuite/libgomp.c/simd-math-1.c
@@ -4,6 +4,7 @@
 /* { dg-do run } */
 /* { dg-options "-O2 -ftree-vectorize -fno-math-errno" } */
 /* { dg-additional-options -foffload-options=amdgcn-amdhsa=-mstack-size=3000000 { target offload_target_amdgcn } } */
+/* { dg-additional-options "-DNONSTDFUNC=1" { target nonstandard_math_functions } } */
 
 #undef PRINT_RESULT
 #define VERBOSE 0
@@ -160,7 +161,9 @@ int main (void)
   TEST_FUN (float, -10.0, 10.0, expf);
   TEST_FUN (float, -10.0, 10.0, exp2f);
   TEST_FUN2 (float, -10.0, 10.0, 100.0, -25.0, fmodf);
+#ifdef NONSTDFUNC
   TEST_FUN (float, -10.0, 10.0, gammaf);
+#endif
   TEST_FUN2 (float, -10.0, 10.0, 15.0, -5.0,hypotf);
   TEST_FUN (float, -10.0, 10.0, lgammaf);
   TEST_FUN (float, -1.0, 50.0, logf);
@@ -169,8 +172,10 @@ int main (void)
   TEST_FUN2 (float, -100.0, 100.0, 100.0, -100.0, powf);
   TEST_FUN2 (float, -50.0, 100.0, -2.0, 40.0, remainderf);
   TEST_FUN (float, -50.0, 50.0, rintf);
+#ifdef NONSTDFUNC
   TEST_FUN2 (float, -50.0, 50.0, -10.0, 32.0, __builtin_scalbf);
   TEST_FUN (float, -10.0, 10.0, __builtin_significandf);
+#endif
   TEST_FUN (float, -3.14159265359, 3.14159265359, sinf);
   TEST_FUN (float, -3.14159265359, 3.14159265359, sinhf);
   TEST_FUN (float, -0.1, 10000.0, sqrtf);
@@ -193,7 +198,9 @@ int main (void)
   TEST_FUN (double, -10.0, 10.0, exp);
   TEST_FUN (double, -10.0, 10.0, exp2);
   TEST_FUN2 (double, -10.0, 10.0, 100.0, -25.0, fmod);
+#ifdef NONSTDFUNC
   TEST_FUN (double, -10.0, 10.0, gamma);
+#endif
   TEST_FUN2 (double, -10.0, 10.0, 15.0, -5.0, hypot);
   TEST_FUN (double, -10.0, 10.0, lgamma);
   TEST_FUN (double, -1.0, 50.0, log);
@@ -202,8 +209,10 @@ int main (void)
   TEST_FUN2 (double, -100.0, 100.0, 100.0, -100.0, pow);
   TEST_FUN2 (double, -50.0, 100.0, -2.0, 40.0, remainder);
   TEST_FUN (double, -50.0, 50.0, rint);
+#ifdef NONSTDFUNC
   TEST_FUN2 (double, -50.0, 50.0, -10.0, 32.0, __builtin_scalb);
   TEST_FUN (double, -10.0, 10.0, __builtin_significand);
+#endif
   TEST_FUN (double, -3.14159265359, 3.14159265359, sin);
   TEST_FUN (double, -3.14159265359, 3.14159265359, sinh);
   TEST_FUN (double, -0.1, 10000.0, sqrt);
-- 
2.39.2 (Apple Git-143)


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

* Re: [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin
  2023-08-22  8:25               ` FX Coudert
@ 2023-08-22 17:10                 ` Jakub Jelinek
  0 siblings, 0 replies; 11+ messages in thread
From: Jakub Jelinek @ 2023-08-22 17:10 UTC (permalink / raw)
  To: FX Coudert; +Cc: Tobias Burnus, GCC Patches

On Tue, Aug 22, 2023 at 10:25:51AM +0200, FX Coudert wrote:
> > Revised patch. I does the job on darwin, can you check that it still tests the functions on Linux?
> > And if so, OK to commit?
> 
> With the correct file, sorry.

Seems to work for me, I see
... -DNONSTDFUNC=1 ...
on the test's command line on linux and the test passes.
So ok.

	Jakub


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

end of thread, other threads:[~2023-08-22 17:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-20 19:37 [PATCH] libgomp, testsuite: Do not call nonstandard functions on darwin FX Coudert
2023-08-21 19:12 ` Tobias Burnus
2023-08-21 19:41   ` Jakub Jelinek
2023-08-21 19:50     ` FX Coudert
2023-08-21 19:55       ` Jakub Jelinek
2023-08-21 20:00         ` FX Coudert
2023-08-21 20:11           ` Jakub Jelinek
2023-08-22  8:16             ` FX Coudert
2023-08-22  8:23               ` Jakub Jelinek
2023-08-22  8:25               ` FX Coudert
2023-08-22 17:10                 ` Jakub Jelinek

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