Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/ieee/fp-cmp-4.c

raw
1 void abort (void);
2 void exit (int);
3
4 #ifndef FLOAT
5 #define FLOAT double
6 #endif
7
8 void
9 test_isunordered(FLOAT x, FLOAT y, int true)
10 {
11 if (__builtin_isunordered(x, y))
12 {
13 if (! true)
14 abort ();
15 }
16 else
17 {
18 if (true)
19 abort ();
20 }
21 }
22
23 void
24 test_isless(FLOAT x, FLOAT y, int true)
25 {
26 if (__builtin_isless(x, y))
27 {
28 if (! true)
29 abort ();
30 }
31 else
32 {
33 if (true)
34 abort ();
35 }
36 }
37
38 void
39 test_islessequal(FLOAT x, FLOAT y, int true)
40 {
41 if (__builtin_islessequal(x, y))
42 {
43 if (! true)
44 abort ();
45 }
46 else
47 {
48 if (true)
49 abort ();
50 }
51 }
52
53 void
54 test_isgreater(FLOAT x, FLOAT y, int true)
55 {
56 if (__builtin_isgreater(x, y))
57 {
58 if (! true)
59 abort ();
60 }
61 else
62 {
63 if (true)
64 abort ();
65 }
66 }
67
68 void
69 test_isgreaterequal(FLOAT x, FLOAT y, int true)
70 {
71 if (__builtin_isgreaterequal(x, y))
72 {
73 if (! true)
74 abort ();
75 }
76 else
77 {
78 if (true)
79 abort ();
80 }
81 }
82
83 void
84 test_islessgreater(FLOAT x, FLOAT y, int true)
85 {
86 if (__builtin_islessgreater(x, y))
87 {
88 if (! true)
89 abort ();
90 }
91 else
92 {
93 if (true)
94 abort ();
95 }
96 }
97
98 #define NAN (0.0 / 0.0)
99
100 int
101 main()
102 {
103 struct try
104 {
105 FLOAT x, y;
106 unsigned unord : 1;
107 unsigned lt : 1;
108 unsigned le : 1;
109 unsigned gt : 1;
110 unsigned ge : 1;
111 unsigned lg : 1;
112 };
113
114 static struct try const data[] =
115 {
116 { NAN, NAN, 1, 0, 0, 0, 0, 0 },
117 { 0.0, NAN, 1, 0, 0, 0, 0, 0 },
118 { NAN, 0.0, 1, 0, 0, 0, 0, 0 },
119 { 0.0, 0.0, 0, 0, 1, 0, 1, 0 },
120 { 1.0, 2.0, 0, 1, 1, 0, 0, 1 },
121 { 2.0, 1.0, 0, 0, 0, 1, 1, 1 },
122 };
123
124 const int n = sizeof(data) / sizeof(data[0]);
125 int i;
126
127 for (i = 0; i < n; ++i)
128 {
129 test_isunordered (data[i].x, data[i].y, data[i].unord);
130 test_isless (data[i].x, data[i].y, data[i].lt);
131 test_islessequal (data[i].x, data[i].y, data[i].le);
132 test_isgreater (data[i].x, data[i].y, data[i].gt);
133 test_isgreaterequal (data[i].x, data[i].y, data[i].ge);
134 test_islessgreater (data[i].x, data[i].y, data[i].lg);
135 }
136
137 exit (0);
138 }