| 1 |
/* Test __bf16 built-in functions. */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "" } */ |
| 4 |
/* { dg-add-options bfloat16 } */ |
| 5 |
/* { dg-add-options ieee } */ |
| 6 |
/* { dg-require-effective-target bfloat16_runtime } */ |
| 7 |
|
| 8 |
extern void exit (int); |
| 9 |
extern void abort (void); |
| 10 |
|
| 11 |
extern __bf16 test_type; |
| 12 |
extern __typeof (__builtin_nansf16b ("")) test_type; |
| 13 |
|
| 14 |
volatile __bf16 inf_cst = (__bf16) __builtin_inff (); |
| 15 |
volatile __bf16 huge_val_cst = (__bf16) __builtin_huge_valf (); |
| 16 |
volatile __bf16 nan_cst = (__bf16) __builtin_nanf (""); |
| 17 |
volatile __bf16 nans_cst = __builtin_nansf16b (""); |
| 18 |
volatile __bf16 neg0 = -0.0bf16, neg1 = -1.0bf16, one = 1.0; |
| 19 |
|
| 20 |
int |
| 21 |
main (void) |
| 22 |
{ |
| 23 |
volatile __bf16 r; |
| 24 |
if (!__builtin_isinf (inf_cst)) |
| 25 |
abort (); |
| 26 |
if (!__builtin_isinf (huge_val_cst)) |
| 27 |
abort (); |
| 28 |
if (inf_cst != huge_val_cst) |
| 29 |
abort (); |
| 30 |
if (!__builtin_isnan (nan_cst)) |
| 31 |
abort (); |
| 32 |
if (!__builtin_isnan (nans_cst)) |
| 33 |
abort (); |
| 34 |
r = __builtin_fabsf (neg1); |
| 35 |
if (r != 1.0bf16) |
| 36 |
abort (); |
| 37 |
r = __builtin_copysignf (one, neg0); |
| 38 |
if (r != neg1) |
| 39 |
abort (); |
| 40 |
r = __builtin_copysignf (inf_cst, neg1); |
| 41 |
if (r != -huge_val_cst) |
| 42 |
abort (); |
| 43 |
r = __builtin_copysignf (-inf_cst, one); |
| 44 |
if (r != huge_val_cst) |
| 45 |
abort (); |
| 46 |
exit (0); |
| 47 |
} |