Debian Codegraph @

gcc/testsuite/gcc.dg/torture/builtin-issignaling-1.c

raw
1 /* { dg-do run } */
2 /* { dg-add-options ieee } */
3 /* { dg-additional-options "-fsignaling-nans" } */
4 /* Workaround for PR57484 on ia32: */
5 /* { dg-additional-options "-msse2 -mfpmath=sse" { target { ia32 && sse2_runtime } } } */
6
7 #if !defined(EXT) && !defined(TYPE)
8 int
9 f1 (void)
10 {
11 return __builtin_issignaling (__builtin_nansf (""));
12 }
13
14 int
15 f2 (void)
16 {
17 return __builtin_issignaling (__builtin_nan (""));
18 }
19
20 int
21 f3 (void)
22 {
23 return __builtin_issignaling (0.0L);
24 }
25
26 int
27 f4 (float x)
28 {
29 return __builtin_issignaling (x);
30 }
31
32 int
33 f5 (double x)
34 {
35 return __builtin_issignaling (x);
36 }
37
38 int
39 f6 (long double x)
40 {
41 return __builtin_issignaling (x);
42 }
43 #else
44 #ifndef TYPE
45 # define CONCATX(X, Y) X ## Y
46 # define CONCAT(X, Y) CONCATX (X, Y)
47 # define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
48 # define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
49
50 # if EXT
51 # define TYPE CONCAT3 (_Float, WIDTH, x)
52 # define CST(C) CONCAT4 (C, f, WIDTH, x)
53 # define FN(F) CONCAT4 (F, f, WIDTH, x)
54 # else
55 # define TYPE CONCAT (_Float, WIDTH)
56 # define CST(C) CONCAT3 (C, f, WIDTH)
57 # define FN(F) CONCAT3 (F, f, WIDTH)
58 # endif
59 #endif
60 #ifndef NANS
61 # define NANS(x) FN (__builtin_nans) (x)
62 #endif
63 #ifndef NAN
64 # define NAN(x) FN (__builtin_nan) (x)
65 #endif
66 #ifndef INF
67 # define INF FN (__builtin_inf) ()
68 #endif
69
70 int
71 f1 (void)
72 {
73 return __builtin_issignaling (NANS (""));
74 }
75
76 int
77 f2 (void)
78 {
79 return __builtin_issignaling (NAN (""));
80 }
81
82 int
83 f3 (void)
84 {
85 return __builtin_issignaling (CST (0.0));
86 }
87
88 int
89 f4 (TYPE x)
90 {
91 return __builtin_issignaling (x);
92 }
93 #endif
94
95 #ifndef EXT
96 float x;
97 double y;
98 long double z;
99 #else
100 TYPE w;
101 #endif
102
103 int
104 main ()
105 {
106 if (!f1 () || f2 () || f3 ())
107 __builtin_abort ();
108 asm volatile ("" : : : "memory");
109 #ifndef EXT
110 if (f4 (x) || !f4 (__builtin_nansf ("0x123")) || f4 (42.0f) || f4 (__builtin_nanf ("0x234"))
111 || f4 (__builtin_inff ()) || f4 (-__builtin_inff ()) || f4 (-42.0f) || f4 (-0.0f) || f4 (0.0f))
112 __builtin_abort ();
113 x = __builtin_nansf ("");
114 asm volatile ("" : : : "memory");
115 if (!f4 (x))
116 __builtin_abort ();
117 if (f5 (y) || !f5 (__builtin_nans ("0x123")) || f5 (42.0) || f5 (__builtin_nan ("0x234"))
118 || f5 (__builtin_inf ()) || f5 (-__builtin_inf ()) || f5 (-42.0) || f5 (-0.0) || f5 (0.0))
119 __builtin_abort ();
120 y = __builtin_nans ("");
121 asm volatile ("" : : : "memory");
122 if (!f5 (y))
123 __builtin_abort ();
124 if (f6 (z) || !f6 (__builtin_nansl ("0x123")) || f6 (42.0L) || f6 (__builtin_nanl ("0x234"))
125 || f6 (__builtin_infl ()) || f6 (-__builtin_infl ()) || f6 (-42.0L) || f6 (-0.0L) || f6 (0.0L))
126 __builtin_abort ();
127 z = __builtin_nansl ("");
128 asm volatile ("" : : : "memory");
129 if (!f6 (z))
130 __builtin_abort ();
131 #else
132 if (f4 (w) || !f4 (NANS ("0x123")) || f4 (CST (42.0)) || f4 (NAN ("0x234"))
133 || f4 (INF) || f4 (-INF) || f4 (CST (-42.0)) || f4 (CST (-0.0)) || f4 (CST (0.0)))
134 __builtin_abort ();
135 w = NANS ("");
136 asm volatile ("" : : : "memory");
137 if (!f4 (w))
138 __builtin_abort ();
139 #endif
140 return 0;
141 }