PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / ieee / fp-cmp-8.c
blob7e24c66d98df9720bc155226d5fedbf825281779
1 #ifndef FLOAT
2 #define FLOAT double
3 #endif
5 /* Like fp-cmp-4.c, but test that the cmove patterns are correct. */
7 static FLOAT
8 test_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
10 return __builtin_isunordered(x, y) ? a : b;
13 static FLOAT
14 test_not_isunordered(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
16 return !__builtin_isunordered(x, y) ? a : b;
19 static FLOAT
20 test_isless(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
22 return __builtin_isless(x, y) ? a : b;
25 static FLOAT
26 test_not_isless(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
28 return !__builtin_isless(x, y) ? a : b;
31 static FLOAT
32 test_islessequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
34 return __builtin_islessequal(x, y) ? a : b;
37 static FLOAT
38 test_not_islessequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
40 return !__builtin_islessequal(x, y) ? a : b;
43 static FLOAT
44 test_isgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
46 return __builtin_isgreater(x, y) ? a : b;
49 static FLOAT
50 test_not_isgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
52 return !__builtin_isgreater(x, y) ? a : b;
55 static FLOAT
56 test_isgreaterequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
58 return __builtin_isgreaterequal(x, y) ? a : b;
61 static FLOAT
62 test_not_isgreaterequal(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
64 return !__builtin_isgreaterequal(x, y) ? a : b;
67 static FLOAT
68 test_islessgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
70 return __builtin_islessgreater(x, y) ? a : b;
73 static FLOAT
74 test_not_islessgreater(FLOAT x, FLOAT y, FLOAT a, FLOAT b)
76 return !__builtin_islessgreater(x, y) ? a : b;
79 static void
80 one_test(FLOAT x, FLOAT y, int expected,
81 FLOAT (*pos) (FLOAT, FLOAT, FLOAT, FLOAT),
82 FLOAT (*neg) (FLOAT, FLOAT, FLOAT, FLOAT))
84 if (((*pos)(x, y, 1.0, 2.0) == 1.0) != expected)
85 abort ();
86 if (((*neg)(x, y, 3.0, 4.0) == 4.0) != expected)
87 abort ();
90 #define NAN (0.0 / 0.0)
91 #define INF (1.0 / 0.0)
93 int
94 main()
96 struct try
98 FLOAT x, y;
99 int result[6];
102 static struct try const data[] =
104 { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },
105 { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },
106 { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },
107 { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
108 { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
109 { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
110 { INF, 0.0, { 0, 0, 0, 1, 1, 1 } },
111 { 1.0, INF, { 0, 1, 1, 0, 0, 1 } },
112 { INF, INF, { 0, 0, 1, 0, 1, 0 } },
113 { 0.0, -INF, { 0, 0, 0, 1, 1, 1 } },
114 { -INF, 1.0, { 0, 1, 1, 0, 0, 1 } },
115 { -INF, -INF, { 0, 0, 1, 0, 1, 0 } },
116 { INF, -INF, { 0, 0, 0, 1, 1, 1 } },
117 { -INF, INF, { 0, 1, 1, 0, 0, 1 } },
120 struct test
122 FLOAT (*pos)(FLOAT, FLOAT, FLOAT, FLOAT);
123 FLOAT (*neg)(FLOAT, FLOAT, FLOAT, FLOAT);
126 static struct test const tests[] =
128 { test_isunordered, test_not_isunordered },
129 { test_isless, test_not_isless },
130 { test_islessequal, test_not_islessequal },
131 { test_isgreater, test_not_isgreater },
132 { test_isgreaterequal, test_not_isgreaterequal },
133 { test_islessgreater, test_not_islessgreater }
136 const int n = sizeof(data) / sizeof(data[0]);
137 int i, j;
139 for (i = 0; i < n; ++i)
140 for (j = 0; j < 6; ++j)
141 one_test (data[i].x, data[i].y, data[i].result[j],
142 tests[j].pos, tests[j].neg);
144 exit (0);