Skip to content

Commit 0ccfbe6

Browse files
committed
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/lib/libgomp.exp: Add effective target. * testsuite/libgomp.c/simd-math-1.c: Avoid calling nonstandard functions.
1 parent 3242fb5 commit 0ccfbe6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

libgomp/testsuite/lib/libgomp.exp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,25 @@ proc offload_target_to_openacc_device_type { offload_target } {
377377
}
378378
}
379379

380+
# Return 1 if certain nonstandard math functions are available
381+
# on the target: gamma, scalb, significand, and their float variants.
382+
proc check_effective_target_nonstandard_math_functions { } {
383+
return [check_no_compiler_messages nonstandard_math_functions executable {
384+
#include <math.h>
385+
int main() {
386+
float x = 42;
387+
double y = 42;
388+
x = gammaf (x);
389+
x = __builtin_scalbf (x, 2.f);
390+
x =__builtin_significandf (x);
391+
y = gamma (y);
392+
y = __builtin_scalb (y, 2.);
393+
y =__builtin_significand (y);
394+
return 0;
395+
}
396+
} "-lm" ]
397+
}
398+
380399
# Return 1 if compiling for the specified offload target
381400
# Takes -foffload=... into account by checking OFFLOAD_TARGET_NAMES=
382401
# in the -v compiler output.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/* { dg-do run } */
55
/* { dg-options "-O2 -ftree-vectorize -fno-math-errno" } */
66
/* { dg-additional-options -foffload-options=amdgcn-amdhsa=-mstack-size=3000000 { target offload_target_amdgcn } } */
7+
/* { dg-additional-options "-DNONSTDFUNC=1" { target nonstandard_math_functions } } */
78

89
#undef PRINT_RESULT
910
#define VERBOSE 0
@@ -160,7 +161,9 @@ int main (void)
160161
TEST_FUN (float, -10.0, 10.0, expf);
161162
TEST_FUN (float, -10.0, 10.0, exp2f);
162163
TEST_FUN2 (float, -10.0, 10.0, 100.0, -25.0, fmodf);
164+
#ifdef NONSTDFUNC
163165
TEST_FUN (float, -10.0, 10.0, gammaf);
166+
#endif
164167
TEST_FUN2 (float, -10.0, 10.0, 15.0, -5.0,hypotf);
165168
TEST_FUN (float, -10.0, 10.0, lgammaf);
166169
TEST_FUN (float, -1.0, 50.0, logf);
@@ -169,8 +172,10 @@ int main (void)
169172
TEST_FUN2 (float, -100.0, 100.0, 100.0, -100.0, powf);
170173
TEST_FUN2 (float, -50.0, 100.0, -2.0, 40.0, remainderf);
171174
TEST_FUN (float, -50.0, 50.0, rintf);
175+
#ifdef NONSTDFUNC
172176
TEST_FUN2 (float, -50.0, 50.0, -10.0, 32.0, __builtin_scalbf);
173177
TEST_FUN (float, -10.0, 10.0, __builtin_significandf);
178+
#endif
174179
TEST_FUN (float, -3.14159265359, 3.14159265359, sinf);
175180
TEST_FUN (float, -3.14159265359, 3.14159265359, sinhf);
176181
TEST_FUN (float, -0.1, 10000.0, sqrtf);
@@ -193,7 +198,9 @@ int main (void)
193198
TEST_FUN (double, -10.0, 10.0, exp);
194199
TEST_FUN (double, -10.0, 10.0, exp2);
195200
TEST_FUN2 (double, -10.0, 10.0, 100.0, -25.0, fmod);
201+
#ifdef NONSTDFUNC
196202
TEST_FUN (double, -10.0, 10.0, gamma);
203+
#endif
197204
TEST_FUN2 (double, -10.0, 10.0, 15.0, -5.0, hypot);
198205
TEST_FUN (double, -10.0, 10.0, lgamma);
199206
TEST_FUN (double, -1.0, 50.0, log);
@@ -202,8 +209,10 @@ int main (void)
202209
TEST_FUN2 (double, -100.0, 100.0, 100.0, -100.0, pow);
203210
TEST_FUN2 (double, -50.0, 100.0, -2.0, 40.0, remainder);
204211
TEST_FUN (double, -50.0, 50.0, rint);
212+
#ifdef NONSTDFUNC
205213
TEST_FUN2 (double, -50.0, 50.0, -10.0, 32.0, __builtin_scalb);
206214
TEST_FUN (double, -10.0, 10.0, __builtin_significand);
215+
#endif
207216
TEST_FUN (double, -3.14159265359, 3.14159265359, sin);
208217
TEST_FUN (double, -3.14159265359, 3.14159265359, sinh);
209218
TEST_FUN (double, -0.1, 10000.0, sqrt);

0 commit comments

Comments
 (0)