1 /* Test various type-generic builtins by calling "main_tests()". */
8 #define fpclassify(X) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, (X))
10 void __attribute__ ((__noinline__
))
11 foo_1 (float f
, double d
, long double ld
,
12 int res_unord
, int res_isnan
, int res_isinf
,
13 int res_isinf_sign
, int res_isfin
, int res_isnorm
,
16 if (__builtin_isunordered (f
, 0) != res_unord
)
18 if (__builtin_isunordered (0, f
) != res_unord
)
20 if (__builtin_isunordered (d
, 0) != res_unord
)
22 if (__builtin_isunordered (0, d
) != res_unord
)
24 if (__builtin_isunordered (ld
, 0) != res_unord
)
26 if (__builtin_isunordered (0, ld
) != res_unord
)
29 if (__builtin_isnan (f
) != res_isnan
)
31 if (__builtin_isnan (d
) != res_isnan
)
33 if (__builtin_isnan (ld
) != res_isnan
)
35 if (__builtin_isnanf (f
) != res_isnan
)
37 if (__builtin_isnanl (ld
) != res_isnan
)
40 if (__builtin_isinf (f
) != res_isinf
)
42 if (__builtin_isinf (d
) != res_isinf
)
44 if (__builtin_isinf (ld
) != res_isinf
)
46 if (__builtin_isinff (f
) != res_isinf
)
48 if (__builtin_isinfl (ld
) != res_isinf
)
51 if (__builtin_isinf_sign (f
) != res_isinf_sign
)
53 if (__builtin_isinf_sign (d
) != res_isinf_sign
)
55 if (__builtin_isinf_sign (ld
) != res_isinf_sign
)
58 if (__builtin_isnormal (f
) != res_isnorm
)
60 if (__builtin_isnormal (d
) != res_isnorm
)
62 if (__builtin_isnormal (ld
) != res_isnorm
)
65 if (__builtin_isfinite (f
) != res_isfin
)
67 if (__builtin_isfinite (d
) != res_isfin
)
69 if (__builtin_isfinite (ld
) != res_isfin
)
72 if (__builtin_finitef (f
) != res_isfin
)
74 if (__builtin_finite (f
) != res_isfin
)
76 if (__builtin_finite (d
) != res_isfin
)
78 if (__builtin_finitel (d
) != res_isfin
)
80 if (__builtin_finitel (ld
) != res_isfin
)
83 /* Subnormals can abruptly underflow to zero in unsafe math
84 mode, so bypass testing these numbers if necessary. */
86 if (classification
!= FP_SUBNORMAL
)
89 if (fpclassify(f
) != classification
)
91 if (fpclassify(d
) != classification
)
93 if (fpclassify(ld
) != classification
)
98 void __attribute__ ((__noinline__
))
99 foo (float f
, double d
, long double ld
,
100 int res_unord
, int res_isnan
, int res_isinf
,
101 int res_isfin
, int res_isnorm
, int classification
)
103 foo_1 (f
, d
, ld
, res_unord
, res_isnan
, res_isinf
, res_isinf
, res_isfin
, res_isnorm
, classification
);
104 /* Try all the values negated as well. */
105 foo_1 (-f
, -d
, -ld
, res_unord
, res_isnan
, res_isinf
, -res_isinf
, res_isfin
, res_isnorm
, classification
);
108 int __attribute__ ((__noinline__
))
113 volatile long double ld
;
116 f
= __builtin_nanf(""); d
= __builtin_nan(""); ld
= __builtin_nanl("");
117 foo(f
, d
, ld
, /*unord=*/ 1, /*isnan=*/ 1, /*isinf=*/ 0, /*isfin=*/ 0, /*isnorm=*/ 0, FP_NAN
);
120 f
= __builtin_inff(); d
= __builtin_inf(); ld
= __builtin_infl();
121 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE
);
124 f
= 0; d
= 0; ld
= 0;
125 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 0, FP_ZERO
);
128 f
= 1; d
= 1; ld
= 1;
129 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL
);
131 /* Test minimum values. */
132 f
= __FLT_MIN__
; d
= __DBL_MIN__
; ld
= __LDBL_MIN__
;
133 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL
);
135 /* Test subnormal values. */
136 f
= __FLT_MIN__
/2; d
= __DBL_MIN__
/2; ld
= __LDBL_MIN__
/2;
137 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 0, FP_SUBNORMAL
);
139 /* Test maximum values. */
140 f
= __FLT_MAX__
; d
= __DBL_MAX__
; ld
= __LDBL_MAX__
;
141 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 0, /*isfin=*/ 1, /*isnorm=*/ 1, FP_NORMAL
);
143 /* Test overflow values. */
144 f
= __FLT_MAX__
*2; d
= __DBL_MAX__
*2; ld
= __LDBL_MAX__
*2;
145 foo(f
, d
, ld
, /*unord=*/ 0, /*isnan=*/ 0, /*isinf=*/ 1, /*isfin=*/ 0, /*isnorm=*/ 0, FP_INFINITE
);