diagnostics: move output formats from diagnostic.{c,h} to their own files
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-5-p9-runnable.c
blob1a5f1d6383abb0dac8f484680fd8d2fcfd54a634
1 /* { dg-do run { target lp64 } } */
2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power9 -O2" } */
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <inttypes.h>
8 #include <altivec.h> // vector
10 #define TRUE 1
11 #define FALSE 0
13 #ifdef DEBUG
14 #include <stdio.h>
15 #endif
17 void abort (void);
19 int result_wrong(vector unsigned char vec_expected,
20 vector unsigned char vec_actual)
22 int i;
24 for (i=0; i<16; i++)
25 if (vec_expected[i] != vec_actual[i])
26 return TRUE;
28 return FALSE;
31 int main() {
32 int i, j;
33 size_t size;
34 unsigned char data_uc[100];
35 vector unsigned char store_data_uc;
36 unsigned char *address;
37 vector unsigned char *datap;
39 vector unsigned char vec_uc_expected1, vec_uc_result1;
40 vector int data_int;
42 for (i=0; i<100; i++)
43 data_uc[i] = i+1;
46 /* VEC_XL_LEN */
48 size = 8;
49 vec_uc_result1 = vec_xl_len (data_uc, size);
51 vec_uc_expected1 = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
52 0, 0, 0, 0, 0, 0, 0, 0};
54 if (result_wrong (vec_uc_expected1, vec_uc_result1))
56 #ifdef DEBUG
57 printf("Error: result does not match expected result\n");
58 printf("vec_xl_len (%d): vec_uc_expected1[0] to vec_uc_expected1[15]\n",
59 size);
61 for (i=0; i<16; i++)
62 printf(" %d,",vec_uc_expected1[i]);
64 printf("\nvec_xl_len (%d): vec_uc_result1[0] to vec_uc_result1[15]\n",
65 size);
67 for (i=0; i<16; i++)
68 printf(" %d,", vec_uc_result1[i]);
70 printf("\n\n");
71 #else
72 abort();
73 #endif
77 /* VEC_XL_LEN_R */
78 size = 8;
79 vec_uc_result1 = vec_xl_len_r(data_uc, size);
81 #ifdef __LITTLE_ENDIAN__
82 vec_uc_expected1 = (vector unsigned char){8, 7, 6, 5, 4, 3, 2, 1,
83 0, 0, 0, 0, 0, 0, 0, 0,};
84 #else
85 vec_uc_expected1 = (vector unsigned char){0, 0, 0, 0, 0, 0, 0, 0,
86 1, 2, 3, 4, 5, 6, 7, 8,};
87 #endif
89 if (result_wrong (vec_uc_expected1, vec_uc_result1))
91 #ifdef DEBUG
92 printf("Error: result does not match expected result\n");
93 printf("vec_xl_len_r(%d): vec_uc_expected1[0] to vec_uc_expected1[15]\n",
94 size);
96 for (i=0; i<16; i++)
97 printf(" %d,", vec_uc_expected1[i]);
99 printf("\nvec_xl_len_r(%d): vec_uc_result1[0] to vec_uc_result1[15]\n",
100 size);
102 for (i=0; i<16; i++)
103 printf(" %d,", vec_uc_result1[i]);
105 printf("\n\n");
106 #else
107 abort();
108 #endif
112 size = 4;
113 vec_uc_result1 = vec_xl_len_r(data_uc, size);
115 #ifdef __LITTLE_ENDIAN__
116 vec_uc_expected1 = (vector unsigned char){ 4, 3, 2, 1, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 0, 0, 0 };
118 #else
119 vec_uc_expected1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
120 0, 0, 0, 0, 1, 2, 3, 4 };
121 #endif
123 if (result_wrong (vec_uc_expected1, vec_uc_result1))
125 #ifdef DEBUG
126 printf("Error: result does not match expected result\n");
127 printf("vec_xl_len_r(%d): vec_uc_expected1[0] to vec_uc_expected1[15]\n",
128 size);
130 for (i=0; i<16; i++)
131 printf(" %d,", vec_uc_expected1[i]);
133 printf("\nvec_xl_len_r(%d): vec_uc_result1[0] to vec_uc_result1[15]\n",
134 size);
136 for (i=0; i<16; i++)
137 printf(" %d,", vec_uc_result1[i]);
139 printf("\n\n");
140 #else
141 abort();
142 #endif
145 size = 2;
146 vec_uc_result1 = vec_xl_len_r(data_uc, size);
148 #ifdef __LITTLE_ENDIAN__
149 vec_uc_expected1 = (vector unsigned char){ 2, 1, 0, 0, 0, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 0, 0 };
151 #else
152 vec_uc_expected1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 0, 1, 2 };
154 #endif
156 if (result_wrong (vec_uc_expected1, vec_uc_result1))
158 #ifdef DEBUG
159 printf("Error: result does not match expected result\n");
160 printf("vec_xl_len_r(%d): vec_uc_expected1[0] to vec_uc_expected1[15]\n",
161 size);
162 for (i=0; i<16; i++)
163 printf(" %d,", vec_uc_expected1[i]);
165 printf("\nvec_xl_len_r(%d) vec_uc_result1[0] to vec_uc_result1[15]\n",
166 size);
168 for (i=0; i<16; i++)
169 printf(" %d,", vec_uc_result1[i]);
171 printf("\n\n");
172 #else
173 abort();
174 #endif
178 /* VEC_XST_LEN */
179 vec_uc_expected1 = (vector unsigned char){ 1, 2, 0, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0 };
181 store_data_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
182 9, 10, 11, 12, 13, 14, 15, 16 };
183 size = 2;
185 for (i=0; i<16; i++)
186 vec_uc_result1[i] = 0;
188 address = &vec_uc_result1[0];
189 vec_xst_len (store_data_uc, address, size);
191 if (result_wrong (vec_uc_expected1, vec_uc_result1))
193 #ifdef DEBUG
194 printf("Error: result does not match expected result\n");
195 printf("vec_xst_len (%d) vec_uc_result1[0] to vec_uc_result1[15]\n",
196 size);
198 for (i=0; i<16; i++)
199 printf(" %d,", vec_uc_expected1[i]);
201 printf("\nvec_xst_len (%d) store_data_uc[0] to store_data_uc[15]\n",
202 size);
204 for (i=0; i<16; i++)
205 printf(" %d,", vec_uc_result1[i]);
207 printf("\n\n");
208 #else
209 abort();
210 #endif
213 vec_uc_expected1 = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
214 9, 10, 11, 12, 13, 14, 0, 0 };
215 store_data_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
216 9, 10, 11, 12, 13, 14, 15, 16 };
217 size = 14;
219 for (i=0; i<16; i++)
220 vec_uc_result1[i] = 0;
222 address = &vec_uc_result1[0];
224 vec_xst_len (store_data_uc, address, size);
226 if (result_wrong (vec_uc_expected1, vec_uc_result1))
228 #ifdef DEBUG
229 printf("Error: result does not match expected result\n");
230 printf("vec_xst_len (%d) vec_uc_result1[0] to vec_uc_result1[15]\n",
231 size);
233 for (i=0; i<16; i++)
234 printf(" %d,", vec_uc_expected1[i]);
236 printf("\nvec_xst_len (%d) store_data_uc[0] to store_data_uc[15]\n",
237 size);
239 for (i=0; i<16; i++)
240 printf(" %d,", vec_uc_result1[i]);
242 printf("\n\n");
243 #else
244 abort();
245 #endif
248 /* VEC_XST_LEN_R */
249 #ifdef __LITTLE_ENDIAN__
250 vec_uc_expected1 = (vector unsigned char){ 16, 15, 14, 13, 12, 11, 10, 9,
251 8, 7, 6, 5, 4, 3, 2, 1 };
252 #else
253 vec_uc_expected1 = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
254 9, 10, 11, 12, 13, 14, 15, 16 };
255 #endif
256 store_data_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
257 9, 10, 11, 12, 13, 14, 15, 16 };
258 vec_uc_result1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
259 0, 0, 0, 0, 0, 0, 0, 0 };
261 size = 16;
263 address = &vec_uc_result1[0];
265 vec_xst_len_r(store_data_uc, address, size);
267 if (result_wrong (vec_uc_expected1, vec_uc_result1))
269 #ifdef DEBUG
270 printf("Error: result does not match expected result\n");
271 printf("vec_xst_len_r(%d) vec_uc_expected1[0] to vec_uc_expected1[15]\n",
272 size);
274 for (i=0; i<16; i++)
275 printf(" %d,", vec_uc_expected1[i]);
277 printf("\nvec_xst_len_r(%d) result[0] to result[15]\n", size);
279 for (i=0; i<16; i++)
280 printf(" %d,", vec_uc_result1[i]);
282 printf("\n\n");
283 #else
284 abort();
285 #endif
288 #ifdef __LITTLE_ENDIAN__
289 vec_uc_expected1 = (vector unsigned char){ 2, 1, 0, 0, 0, 0, 0, 0,
290 0, 0, 0, 0, 0, 0, 0, 0 };
291 #else
292 vec_uc_expected1 = (vector unsigned char){ 15, 16, 0, 0, 0, 0, 0, 0,
293 0, 0, 0, 0, 0, 0, 0, 0 };
294 #endif
295 store_data_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
296 9, 10, 11, 12, 13, 14, 15, 16 };
297 vec_uc_result1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
298 0, 0, 0, 0, 0, 0, 0, 0 };
300 size = 2;
302 address = &vec_uc_result1[0];
304 vec_xst_len_r(store_data_uc, address, size);
306 if (result_wrong (vec_uc_expected1, vec_uc_result1))
308 #ifdef DEBUG
309 printf("Error: result does not match expected result\n");
310 printf("vec_xst_len_r(%d) vec_uc_expected1[0] to vec_uc_expected1[15]\n",
311 size);
313 for (i=0; i<16; i++)
314 printf(" %d,", vec_uc_expected1[i]);
316 printf("\nvec_xst_len_r(%d) result[0] to result[15]\n", size);
318 for (i=0; i<16; i++)
319 printf(" %d,", vec_uc_result1[i]);
321 printf("\n\n");
322 #else
323 abort();
324 #endif
327 #ifdef __LITTLE_ENDIAN__
328 vec_uc_expected1 = (vector unsigned char){ 16, 15, 14, 13, 12, 11, 10, 9,
329 8, 7, 6, 5, 4, 3, 2, 1 };
330 #else
331 vec_uc_expected1 = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
332 9, 10, 11, 12, 13, 14, 15, 16 };
333 #endif
334 store_data_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
335 9, 10, 11, 12, 13, 14, 15, 16 };
336 vec_uc_result1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
337 0, 0, 0, 0, 0, 0, 0, 0 };
339 size = 16;
341 address = &vec_uc_result1[0];
343 vec_xst_len_r(store_data_uc, address, size);
345 if (result_wrong (vec_uc_expected1, vec_uc_result1))
347 #ifdef DEBUG
348 printf("Error: result does not match expected result\n");
349 printf("vec_xst_len_r(%d) vec_uc_expected1[0] to vec_uc_expected1[15]\n",
350 size);
352 for (i=0; i<16; i++)
353 printf(" %d,", vec_uc_expected1[i]);
355 printf("\nvec_xst_len_r(%d) result[0] to result[15]\n", size);
357 for (i=0; i<16; i++)
358 printf(" %d,", vec_uc_result1[i]);
360 printf("\n\n");
361 #else
362 abort();
363 #endif
366 #ifdef __LITTLE_ENDIAN__
367 vec_uc_expected1 = (vector unsigned char){ 14, 13, 12, 11, 10, 9, 8, 7,
368 6, 5, 4, 3, 2, 1, 0, 0 };
369 #else
370 vec_uc_expected1 = (vector unsigned char){ 3, 4, 5, 6, 7, 8, 9, 10,
371 11, 12, 13, 14, 15, 16, 0, 0 };
372 #endif
373 store_data_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8,
374 9, 10, 11, 12, 13, 14, 15, 16 };
375 vec_uc_result1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
376 0, 0, 0, 0, 0, 0, 0, 0 };
378 size = 14;
380 address = &vec_uc_result1[0];
382 vec_xst_len_r(store_data_uc, address, size);
384 if (result_wrong (vec_uc_expected1, vec_uc_result1))
386 #ifdef DEBUG
387 printf("Error: result does not match expected result\n");
388 printf("vec_xst_len_r(%d) vec_uc_expected1[0] to vec_uc_expected1[15]\n",
389 size);
391 for (i=0; i<16; i++)
392 printf(" %d,", vec_uc_expected1[i]);
394 printf("\nvec_xst_len_r(%d) result[0] to result[15]\n", size);
396 for (i=0; i<16; i++)
397 printf(" %d,", vec_uc_result1[i]);
399 printf("\n\n");
400 #else
401 abort();
402 #endif