2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / mips / mips-3d-6.c
blobe6b44f075851b0df9ee6263fd66ef08bf4ec6936
1 /* { dg-do run } */
2 /* { dg-options "-mips3d" } */
4 /* Test MIPS-3D absolute compare (floats) builtin functions */
5 #include <stdlib.h>
6 #include <stdio.h>
8 NOMIPS16 int test0 (float a, float b);
9 NOMIPS16 int test1 (float a, float b);
10 NOMIPS16 int test2 (float a, float b);
11 NOMIPS16 int test3 (float a, float b);
12 NOMIPS16 int test4 (float a, float b);
13 NOMIPS16 int test5 (float a, float b);
14 NOMIPS16 int test6 (float a, float b);
15 NOMIPS16 int test7 (float a, float b);
16 NOMIPS16 int test8 (float a, float b);
17 NOMIPS16 int test9 (float a, float b);
18 NOMIPS16 int test10 (float a, float b);
19 NOMIPS16 int test11 (float a, float b);
20 NOMIPS16 int test12 (float a, float b);
21 NOMIPS16 int test13 (float a, float b);
22 NOMIPS16 int test14 (float a, float b);
23 NOMIPS16 int test15 (float a, float b);
25 NOMIPS16 int main ()
27 float a, b;
28 int i;
30 /* cabs.eq.s */
31 a = 12;
32 b = -56;
33 i = 0;
34 if (__builtin_mips_cabs_eq_s(a, b) != i)
35 abort ();
37 /* cabs.eq.s */
38 a = 12;
39 b = -12;
40 i = 1;
41 if (__builtin_mips_cabs_eq_s(a, b) != i)
42 abort ();
44 /* Test all comparisons */
45 a = 10.58;
46 b = 567.345;
48 i = test0 (a, b);
49 if (i != 0)
50 abort ();
51 i = test1 (a, b);
52 if (i != 0)
53 abort ();
54 i = test2 (a, b);
55 if (i != 0)
56 abort ();
57 i = test3 (a, b);
58 if (i != 0)
59 abort ();
60 i = test4 (a, b);
61 if (i != 1)
62 abort ();
63 i = test5 (a, b);
64 if (i != 1)
65 abort ();
66 i = test6 (a, b);
67 if (i != 1)
68 abort ();
69 i = test7 (a, b);
70 if (i != 1)
71 abort ();
72 i = test8 (a, b);
73 if (i != 0)
74 abort ();
75 i = test9 (a, b);
76 if (i != 0)
77 abort ();
78 i = test10 (a, b);
79 if (i != 0)
80 abort ();
81 i = test11 (a, b);
82 if (i != 0)
83 abort ();
84 i = test12 (a, b);
85 if (i != 1)
86 abort ();
87 i = test13 (a, b);
88 if (i != 1)
89 abort ();
90 i = test14 (a, b);
91 if (i != 1)
92 abort ();
93 i = test15 (a, b);
94 if (i != 1)
95 abort ();
97 /* Reversed arguments */
98 i = test0 (b, a);
99 if (i != 0)
100 abort ();
101 i = test1 (b, a);
102 if (i != 0)
103 abort ();
104 i = test2 (b, a);
105 if (i != 0)
106 abort ();
107 i = test3 (b, a);
108 if (i != 0)
109 abort ();
110 i = test4 (b, a);
111 if (i != 0)
112 abort ();
113 i = test5 (b, a);
114 if (i != 0)
115 abort ();
116 i = test6 (b, a);
117 if (i != 0)
118 abort ();
119 i = test7 (b, a);
120 if (i != 0)
121 abort ();
122 i = test8 (b, a);
123 if (i != 0)
124 abort ();
125 i = test9 (b, a);
126 if (i != 0)
127 abort ();
128 i = test10 (b, a);
129 if (i != 0)
130 abort ();
131 i = test11 (b, a);
132 if (i != 0)
133 abort ();
134 i = test12 (b, a);
135 if (i != 0)
136 abort ();
137 i = test13 (b, a);
138 if (i != 0)
139 abort ();
140 i = test14 (b, a);
141 if (i != 0)
142 abort ();
143 i = test15 (b, a);
144 if (i != 0)
145 abort ();
147 #ifndef __FAST_MATH__
148 /* Test all comparisons */
149 a = 1.0f/0.0f - 1.0f/0.0f; // QNaN
150 b = 567.345;
152 i = test0 (a, b);
153 if (i != 0)
154 abort ();
155 i = test1 (a, b);
156 if (i != 1)
157 abort ();
158 i = test2 (a, b);
159 if (i != 0)
160 abort ();
161 i = test3 (a, b);
162 if (i != 1)
163 abort ();
164 i = test4 (a, b);
165 if (i != 0)
166 abort ();
167 i = test5 (a, b);
168 if (i != 1)
169 abort ();
170 i = test6 (a, b);
171 if (i != 0)
172 abort ();
173 i = test7 (a, b);
174 if (i != 1)
175 abort ();
176 i = test8 (a, b);
177 if (i != 0)
178 abort ();
179 i = test9 (a, b);
180 if (i != 1)
181 abort ();
182 i = test10 (a, b);
183 if (i != 0)
184 abort ();
185 i = test11 (a, b);
186 if (i != 1)
187 abort ();
188 i = test12 (a, b);
189 if (i != 0)
190 abort ();
191 i = test13 (a, b);
192 if (i != 1)
193 abort ();
194 i = test14 (a, b);
195 if (i != 0)
196 abort ();
197 i = test15 (a, b);
198 if (i != 1)
199 abort ();
200 #endif
202 printf ("Test Passes\n");
203 exit (0);
206 NOMIPS16 int test0 (float a, float b)
208 return __builtin_mips_cabs_f_s (a, b);
211 NOMIPS16 int test1 (float a, float b)
213 return __builtin_mips_cabs_un_s (a, b);
216 NOMIPS16 int test2 (float a, float b)
218 return __builtin_mips_cabs_eq_s (a, b);
221 NOMIPS16 int test3 (float a, float b)
223 return __builtin_mips_cabs_ueq_s (a, b);
226 NOMIPS16 int test4 (float a, float b)
228 return __builtin_mips_cabs_olt_s (a, b);
231 NOMIPS16 int test5 (float a, float b)
233 return __builtin_mips_cabs_ult_s (a, b);
236 NOMIPS16 int test6 (float a, float b)
238 return __builtin_mips_cabs_ole_s (a, b);
241 NOMIPS16 int test7 (float a, float b)
243 return __builtin_mips_cabs_ule_s (a, b);
246 NOMIPS16 int test8 (float a, float b)
248 return __builtin_mips_cabs_sf_s (a, b);
251 NOMIPS16 int test9 (float a, float b)
253 return __builtin_mips_cabs_ngle_s (a, b);
256 NOMIPS16 int test10 (float a, float b)
258 return __builtin_mips_cabs_seq_s (a, b);
261 NOMIPS16 int test11 (float a, float b)
263 return __builtin_mips_cabs_ngl_s (a, b);
266 NOMIPS16 int test12 (float a, float b)
268 return __builtin_mips_cabs_lt_s (a, b);
271 NOMIPS16 int test13 (float a, float b)
273 return __builtin_mips_cabs_nge_s (a, b);
276 NOMIPS16 int test14 (float a, float b)
278 return __builtin_mips_cabs_le_s (a, b);
281 NOMIPS16 int test15 (float a, float b)
283 return __builtin_mips_cabs_ngt_s (a, b);