2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / ieee / fp-cmp-8.c
blob225539b83eb1b6160cdde52cf098d55c802cd1a4
1 /* Like fp-cmp-4.c, but test that the cmove patterns are correct. */
3 static double
4 test_isunordered(double x, double y, double a, double b)
6 return __builtin_isunordered(x, y) ? a : b;
9 static double
10 test_not_isunordered(double x, double y, double a, double b)
12 return !__builtin_isunordered(x, y) ? a : b;
15 static double
16 test_isless(double x, double y, double a, double b)
18 return __builtin_isless(x, y) ? a : b;
21 static double
22 test_not_isless(double x, double y, double a, double b)
24 return !__builtin_isless(x, y) ? a : b;
27 static double
28 test_islessequal(double x, double y, double a, double b)
30 return __builtin_islessequal(x, y) ? a : b;
33 static double
34 test_not_islessequal(double x, double y, double a, double b)
36 return !__builtin_islessequal(x, y) ? a : b;
39 static double
40 test_isgreater(double x, double y, double a, double b)
42 return __builtin_isgreater(x, y) ? a : b;
45 static double
46 test_not_isgreater(double x, double y, double a, double b)
48 return !__builtin_isgreater(x, y) ? a : b;
51 static double
52 test_isgreaterequal(double x, double y, double a, double b)
54 return __builtin_isgreaterequal(x, y) ? a : b;
57 static double
58 test_not_isgreaterequal(double x, double y, double a, double b)
60 return !__builtin_isgreaterequal(x, y) ? a : b;
63 static double
64 test_islessgreater(double x, double y, double a, double b)
66 return __builtin_islessgreater(x, y) ? a : b;
69 static double
70 test_not_islessgreater(double x, double y, double a, double b)
72 return !__builtin_islessgreater(x, y) ? a : b;
75 static void
76 one_test(double x, double y, int expected,
77 double (*pos) (double, double, double, double),
78 double (*neg) (double, double, double, double))
80 if (((*pos)(x, y, 1.0, 2.0) == 1.0) != expected)
81 abort ();
82 if (((*neg)(x, y, 3.0, 4.0) == 4.0) != expected)
83 abort ();
86 #define NAN (0.0 / 0.0)
87 #define INF (1.0 / 0.0)
89 int
90 main()
92 struct try
94 double x, y;
95 int result[6];
98 static struct try const data[] =
100 { NAN, NAN, { 1, 0, 0, 0, 0, 0 } },
101 { 0.0, NAN, { 1, 0, 0, 0, 0, 0 } },
102 { NAN, 0.0, { 1, 0, 0, 0, 0, 0 } },
103 { 0.0, 0.0, { 0, 0, 1, 0, 1, 0 } },
104 { 1.0, 2.0, { 0, 1, 1, 0, 0, 1 } },
105 { 2.0, 1.0, { 0, 0, 0, 1, 1, 1 } },
106 { INF, 0.0, { 0, 0, 0, 1, 1, 1 } },
107 { 1.0, INF, { 0, 1, 1, 0, 0, 1 } },
108 { INF, INF, { 0, 0, 1, 0, 1, 0 } },
109 { 0.0, -INF, { 0, 0, 0, 1, 1, 1 } },
110 { -INF, 1.0, { 0, 1, 1, 0, 0, 1 } },
111 { -INF, -INF, { 0, 0, 1, 0, 1, 0 } },
112 { INF, -INF, { 0, 0, 0, 1, 1, 1 } },
113 { -INF, INF, { 0, 1, 1, 0, 0, 1 } },
116 struct test
118 double (*pos)(double, double, double, double);
119 double (*neg)(double, double, double, double);
122 static struct test const tests[] =
124 { test_isunordered, test_not_isunordered },
125 { test_isless, test_not_isless },
126 { test_islessequal, test_not_islessequal },
127 { test_isgreater, test_not_isgreater },
128 { test_isgreaterequal, test_not_isgreaterequal },
129 { test_islessgreater, test_not_islessgreater }
132 const int n = sizeof(data) / sizeof(data[0]);
133 int i, j;
135 for (i = 0; i < n; ++i)
136 for (j = 0; j < 6; ++j)
137 one_test (data[i].x, data[i].y, data[i].result[j],
138 tests[j].pos, tests[j].neg);
140 exit (0);