]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp, testsuite: Do not call nonstandard functions
authorFrancois-Xavier Coudert <fxcoudert@gmail.com>
Tue, 22 Aug 2023 08:15:00 +0000 (10:15 +0200)
committerFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Tue, 22 Aug 2023 22:49:08 +0000 (00:49 +0200)
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/lib/libgomp.exp: Add effective target.
* testsuite/libgomp.c/simd-math-1.c: Avoid calling nonstandard
functions.

libgomp/testsuite/lib/libgomp.exp
libgomp/testsuite/libgomp.c/simd-math-1.c

index 2f9e538278fd9513e84acb2c102f911bdd0d859e..a143b5d0defa1bb87bf7c28f8355c1fc29830d8b 100644 (file)
@@ -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.
index dd2077cc5973b307787c366a3958ef293a9c56c9..42a008c80fc8317554462e24b13b1be01e1f1a0b 100644 (file)
@@ -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);