[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-8-p9-runnable.c
blobf4809e6afff97b14f12eef02ce2cb34bb1cfd752
1 /* { dg-do run } */
2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power9 -O2" } */
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <altivec.h> // vector
9 #ifdef DEBUG
10 #include <stdio.h>
11 #endif
13 #ifdef DEBUG2
14 #include <stdio.h>
15 #endif
18 void abort (void);
20 #ifdef DEBUG2
21 void print_signed_char (char *name, vector signed char src)
23 int i;
25 for (i = 0; i < 8; i++)
26 printf("%s[%d] = %d, ", name, i, src[i]);
28 printf("\n");
30 for (i = 8; i < 15; i++)
31 printf("%s[%d] = %d, ", name, i, src[i]);
33 printf("%s[%d] = %d\n", name, 15, src[i]);
36 void print_unsigned_char (char *name, vector unsigned char src)
38 int i;
40 for (i = 0; i < 8; i++)
41 printf("%s[%d] = %d, ", name, i, src[i]);
43 printf("\n");
45 for (i = 8; i < 15; i++)
46 printf("%s[%d] = %d, ", name, i, src[i]);
48 printf("%s[%d] = %d\n", name, 15, src[i]);
51 void print_signed_short_int (char *name, vector signed short int src)
53 int i;
55 for (i = 0; i < 7; i++)
56 printf("%s[%d] = %d, ", name, i, src[i]);
58 printf("%s[%d] = %d\n", name, 7, src[i]);
61 void print_unsigned_short_int (char *name, vector unsigned short int src)
63 int i;
65 for (i = 0; i < 7; i++)
66 printf("%s[%d] = %d, ", name, i, src[i]);
68 printf("%s[%d] = %d\n", name, 7, src[i]);
71 void print_signed_int (char *name, vector signed int src)
73 int i;
75 for (i = 0; i < 3; i++)
76 printf("%s[%d] = %d, ", name, i, src[i]);
78 printf("%s[%d] = %d\n", name, 3, src[i]);
81 void print_unsigned_int (char *name, vector unsigned int src)
83 int i;
85 for (i = 0; i < 3; i++)
86 printf("%s[%d] = %d, ", name, i, src[i]);
88 printf("%s[%d] = %d\n", name, 3, src[i]);
90 #endif
92 int main() {
94 vector signed char char_src1, char_src2;
95 vector unsigned char uchar_src1, uchar_src2;
96 vector signed short int short_src1, short_src2;
97 vector unsigned short int ushort_src1, ushort_src2;
98 vector signed int int_src1, int_src2;
99 vector unsigned int uint_src1, uint_src2;
100 unsigned int result, expected_result;
103 /* Tests for: vec_first_match_index()
104 The element index in natural element order is returned for the
105 first match or the number of elements if there is no match. */
106 /* char */
107 char_src1 = (vector signed char) { 0x40, 0, 0x40, 0x40,
108 0x40, 0x40, 0x40, 0x40,
109 0x40, 0x40, 0x40, 0x40,
110 0x40, 0x40, 0x40, 0x40 };
112 char_src2 = (vector signed char) {0, 0, 0, 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 0, 0, 0};
114 expected_result = 1;
116 result = vec_first_match_index (char_src1, char_src2);
118 #ifdef DEBUG2
119 print_signed_char("src1", char_src1);
120 print_signed_char("src2", char_src2);
121 printf(" vec_first_match_index = %d\n\n", result);
122 #endif
124 if (result != expected_result)
125 #ifdef DEBUG
126 printf("Error: char first match result (%d) does not match expected result (%d)\n",
127 result, expected_result);
128 #else
129 abort();
130 #endif
132 char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
133 9, 10, 11, 12, 13, 14, 15, 16};
134 char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
135 9, 10, 11, 12, 13, 14, 15, 16};
136 expected_result = 0;
138 result = vec_first_match_index (char_src1, char_src2);
140 #ifdef DEBUG2
141 print_signed_char("src1", char_src1);
142 print_signed_char("src2", char_src2);
143 printf(" vec_first_match_index = %d\n\n", result);
144 #endif
146 if (result != expected_result)
147 #ifdef DEBUG
148 printf("Error: char first match result (%d) does not match expected result (%d)\n",
149 result, expected_result);
150 #else
151 abort();
152 #endif
154 char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
155 9, 10, 11, 12, 13, 14, 15, 16};
156 char_src2 = (vector signed char) {-1, -2, -3, -4, -5, -6, -7, -8,
157 -9, -10, -11, -12, -13, -14, -15, -16};
158 expected_result = 16;
160 result = vec_first_match_index (char_src1, char_src2);
162 #ifdef DEBUG2
163 print_signed_char("src1", char_src1);
164 print_signed_char("src2", char_src2);
165 printf("vec_first_match_index = %d\n\n", result);
166 #endif
168 if (result != expected_result)
169 #ifdef DEBUG
170 printf("Error: char first match result (%d) does not match expected result (%d)\n",
171 result, expected_result);
172 #else
173 abort();
174 #endif
176 uchar_src1 = (vector unsigned char) {0, 2, 3, 4, 5, 6, 7, 8,
177 9, 10, 11, 12, 13, 14, 15, 16};
178 uchar_src2 = (vector unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
179 9, 10, 11, 12, 13, 14, 15, 16};
180 expected_result = 2;
182 result = vec_first_match_index (uchar_src1, uchar_src2);
184 #ifdef DEBUG2
185 print_unsigned_char("src1", uchar_src1);
186 print_unsigned_char("src2", uchar_src2);
187 printf("vec_first_match_index = %d\n\n", result);
188 #endif
190 if (result != expected_result)
191 #ifdef DEBUG
192 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
193 result, expected_result);
194 #else
195 abort();
196 #endif
198 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
199 10, 11, 12, 13, 14, 15, 16, 17};
200 uchar_src2 = (vector unsigned char) {3, 4, 5, 6, 7, 8, 9, 10,
201 11, 12, 13, 14, 15, 16, 17, 18};
202 expected_result = 16;
204 result = vec_first_match_index (uchar_src1, uchar_src2);
206 #ifdef DEBUG2
207 print_unsigned_char("src1", uchar_src1);
208 print_unsigned_char("src2", uchar_src2);
209 printf("vec_first_match_index = %d\n\n", result);
210 #endif
212 if (result != expected_result)
213 #ifdef DEBUG
214 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
215 result, expected_result);
216 #else
217 abort();
218 #endif
220 /* short int */
221 short_src1 = (vector short int) {10, -20, -30, 40, 50, 60, 70, 80};
222 short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
224 expected_result = 3;
226 result = vec_first_match_index (short_src1, short_src2);
228 #ifdef DEBUG2
229 print_signed_short_int("src1", short_src1);
230 print_signed_short_int("src2", short_src2);
231 printf("vec_first_match_index = %d\n\n", result);
232 #endif
234 if (result != expected_result)
235 #ifdef DEBUG
236 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
237 result, expected_result);
238 #else
239 abort();
240 #endif
242 short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
243 short_src2 = (vector short int) {0, 0, 0, 0, 0, 0, 0, 0};
245 expected_result = 8;
247 result = vec_first_match_index (short_src1, short_src2);
249 #ifdef DEBUG2
250 print_signed_short_int("src1", short_src1);
251 print_signed_short_int("src2", short_src2);
252 printf("vec_first_match_index = %d\n\n", result);
253 #endif
255 if (result != expected_result)
256 #ifdef DEBUG
257 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
258 result, expected_result);
259 #else
260 abort();
261 #endif
263 ushort_src1 = (vector short unsigned int) {0, 0, 0, 0, 0, 60, 70, 0};
264 ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
266 expected_result = 5;
268 result = vec_first_match_index (ushort_src1, ushort_src2);
270 #ifdef DEBUG2
271 print_unsigned_short_int("src1", ushort_src1);
272 print_unsigned_short_int("src2", ushort_src2);
273 printf("vec_first_match_index = %d\n\n", result);
274 #endif
276 if (result != expected_result)
277 #ifdef DEBUG
278 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
279 result, expected_result);
280 #else
281 abort();
282 #endif
284 ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
285 60, -70, 80, -90};
286 ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
287 -60, 70, -80, 90};
289 expected_result = 8;
291 result = vec_first_match_index (ushort_src1, ushort_src2);
293 #ifdef DEBUG2
294 print_unsigned_short_int("src1", ushort_src1);
295 print_unsigned_short_int("src2", ushort_src2);
296 printf("vec_first_match_index = %d\n\n", result);
297 #endif
299 if (result != expected_result)
300 #ifdef DEBUG
301 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
302 result, expected_result);
303 #else
304 abort();
305 #endif
307 /* int */
308 int_src1 = (vector int) {1, 2, 3, 4};
309 int_src2 = (vector int) {10, 20, 30, 4};
311 expected_result = 3;
313 result = vec_first_match_index (int_src1, int_src2);
315 #ifdef DEBUG2
316 print_signed_int("src1", int_src1);
317 print_signed_int("src2", int_src2);
318 printf("vec_first_match_index = %d\n\n", result);
319 #endif
321 if (result != expected_result)
322 #ifdef DEBUG
323 printf("Error: int first match result (%d) does not match expected result (%d)\n",
324 result, expected_result);
325 #else
326 abort();
327 #endif
329 int_src1 = (vector int) {1, 2, 3, 4};
330 int_src2 = (vector int) {4, 3, 2, 1};
332 expected_result = 4;
334 result = vec_first_match_index (int_src1, int_src2);
336 #ifdef DEBUG2
337 print_signed_int("src1", int_src1);
338 print_signed_int("src2", int_src2);
339 printf("vec_first_match_index = %d\n\n", result);
340 #endif
342 if (result != expected_result)
343 #ifdef DEBUG
344 printf("Error: int first match result (%d) does not match expected result (%d)\n",
345 result, expected_result);
346 #else
347 abort();
348 #endif
350 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
351 uint_src2 = (vector unsigned int) {11, 2, 33, 4};
353 expected_result = 1;
355 result = vec_first_match_index (uint_src1, uint_src2);
357 #ifdef DEBUG2
358 print_unsigned_int("src1", uint_src1);
359 print_unsigned_int("src2", uint_src2);
360 printf("vec_first_match_index = %d\n\n", result);
361 #endif
363 if (result != expected_result)
364 #ifdef DEBUG
365 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
366 result, expected_result);
367 #else
368 abort();
369 #endif
371 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
372 uint_src2 = (vector unsigned int) {2, 3, 4, 5};
374 expected_result = 4;
376 result = vec_first_match_index (uint_src1, uint_src2);
378 #ifdef DEBUG2
379 print_unsigned_int("src1", uint_src1);
380 print_unsigned_int("src2", uint_src2);
381 printf("vec_first_match_index = %d\n\n", result);
382 #endif
384 if (result != expected_result)
385 #ifdef DEBUG
386 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
387 result, expected_result);
388 #else
389 abort();
390 #endif
392 /* Tests for: vec_first_mismatch_index()
393 The element index in BE order is returned for the first mismatch
394 or the number of elements if there is no match. */
395 /* char */
396 char_src1 = (vector signed char) {1, 2, 0, 4, -5, 6, 7, 8,
397 9, 10, 11, 12, 13, 14, 15, 16};
398 char_src2 = (vector signed char) {1, 2, 0, 20, -5, 6, 7, 8,
399 9, 10, 11, 12, 13, 14, 15, 16};
400 expected_result = 3;
402 result = vec_first_mismatch_index (char_src1, char_src2);
404 #ifdef DEBUG2
405 print_signed_char("src1", char_src1);
406 print_signed_char("src2", char_src2);
407 printf("vec_first_mismatch_index = %d\n\n", result);
408 #endif
410 if (result != expected_result)
411 #ifdef DEBUG
412 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
413 result, expected_result);
414 #else
415 abort();
416 #endif
418 char_src1 = (vector signed char) {0, 2, 3, 4, -5, 6, 7, 8,
419 9, 10, 11, 12, 13, 14, 15, 16};
420 char_src2 = (vector signed char) {0, 2, 3, 20, -5, 6, 7, 8,
421 9, 10, 11, 12, 13, 14, 15, 16};
422 expected_result = 3;
424 result = vec_first_mismatch_index (char_src1, char_src2);
426 #ifdef DEBUG2
427 print_signed_char("src1", char_src1);
428 print_signed_char("src2", char_src2);
429 printf("vec_first_mismatch_index = %d\n\n", result);
430 #endif
432 if (result != expected_result)
433 #ifdef DEBUG
434 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
435 result, expected_result);
436 #else
437 abort();
438 #endif
440 char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
441 9, 10, 11, 12, 13, 14, 15, 16};
442 char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
443 9, 10, 11, 12, 13, 14, 15, 16};
444 expected_result = 3;
446 result = vec_first_mismatch_index (char_src1, char_src2);
448 #ifdef DEBUG2
449 print_signed_char("src1", char_src1);
450 print_signed_char("src2", char_src2);
451 printf("vec_first_mismatch_index = %d\n\n", result);
452 #endif
454 if (result != expected_result)
455 #ifdef DEBUG
456 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
457 result, expected_result);
458 #else
459 abort();
460 #endif
462 char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
463 9, 10, 11, 12, 13, 14, 15, 16};
464 char_src2 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
465 9, 10, 11, 12, 13, 14, 15, 16};
466 expected_result = 16;
468 result = vec_first_mismatch_index (char_src1, char_src2);
470 #ifdef DEBUG2
471 print_signed_char("src1", char_src1);
472 print_signed_char("src2", char_src2);
473 printf("vec_first_mismatch_index = %d\n\n", result);
474 #endif
476 if (result != expected_result)
477 #ifdef DEBUG
478 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
479 result, expected_result);
480 #else
481 abort();
482 #endif
484 uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
485 9, 10, 11, 12, 13, 14, 15, 16};
486 uchar_src2 = (vector unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
487 9, 10, 11, 12, 13, 14, 15, 16};
488 expected_result = 1;
490 result = vec_first_mismatch_index (uchar_src1, uchar_src2);
492 #ifdef DEBUG2
493 print_unsigned_char("src1", uchar_src1);
494 print_unsigned_char("src2", uchar_src2);
495 printf("vec_first_mismatch_index = %d\n\n", result);
496 #endif
498 if (result != expected_result)
499 #ifdef DEBUG
500 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
501 result, expected_result);
502 #else
503 abort();
504 #endif
506 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
507 10, 11, 12, 13, 14, 15, 16};
508 uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
509 0, 11, 12, 13, 14, 15, 16};
510 expected_result = 8;
512 result = vec_first_mismatch_index (uchar_src1, uchar_src2);
514 #ifdef DEBUG2
515 print_unsigned_char("src1", uchar_src1);
516 print_unsigned_char("src2", uchar_src2);
517 printf("vec_first_mismatch_index = %d\n\n", result);
518 #endif
520 if (result != expected_result)
521 #ifdef DEBUG
522 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
523 result, expected_result);
524 #else
525 abort();
526 #endif
528 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
529 10, 11, 12, 13, 14, 15, 16};
530 uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
531 10, 11, 12, 13, 14, 15, 16};
532 expected_result = 16;
534 result = vec_first_mismatch_index (uchar_src1, uchar_src2);
536 #ifdef DEBUG2
537 print_unsigned_char("src1", uchar_src1);
538 print_unsigned_char("src2", uchar_src2);
539 printf("vec_first_mismatch_index = %d\n\n", result);
540 #endif
542 if (result != expected_result)
543 #ifdef DEBUG
544 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
545 result, expected_result);
546 #else
547 abort();
548 #endif
550 /* short int */
551 short_src1 = (vector short int) {-10, -20, 30, 40, 50, 60, 70, 80};
552 short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
554 expected_result = 1;
556 result = vec_first_mismatch_index (short_src1, short_src2);
558 #ifdef DEBUG2
559 print_signed_short_int("src1", short_src1);
560 print_signed_short_int("src2", short_src2);
561 printf("vec_first_mismatch_index = %d\n\n", result);
562 #endif
564 if (result != expected_result)
565 #ifdef DEBUG
566 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
567 result, expected_result);
568 #else
569 abort();
570 #endif
572 short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
573 short_src2 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
575 expected_result = 8;
577 result = vec_first_mismatch_index (short_src1, short_src2);
579 #ifdef DEBUG2
580 print_signed_short_int("src1", short_src1);
581 print_signed_short_int("src2", short_src2);
582 printf("vec_first_mismatch_index = %d\n\n", result);
583 #endif
585 if (result != expected_result)
586 #ifdef DEBUG
587 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
588 result, expected_result);
589 #else
590 abort();
591 #endif
593 ushort_src1 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 0};
594 ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
596 expected_result = 7;
598 result = vec_first_mismatch_index (ushort_src1, ushort_src2);
600 #ifdef DEBUG2
601 print_unsigned_short_int("src1", ushort_src1);
602 print_unsigned_short_int("src2", ushort_src2);
603 printf("vec_first_mismatch_index = %d\n\n", result);
604 #endif
606 if (result != expected_result)
607 #ifdef DEBUG
608 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
609 result, expected_result);
610 #else
611 abort();
612 #endif
614 ushort_src1 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
615 ushort_src2 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
617 expected_result = 8;
619 result = vec_first_mismatch_index (ushort_src1, ushort_src2);
621 #ifdef DEBUG2
622 print_unsigned_short_int("src1", ushort_src1);
623 print_unsigned_short_int("src2", ushort_src2);
624 printf("vec_first_mismatch_index = %d\n\n", result);
625 #endif
627 if (result != expected_result)
628 #ifdef DEBUG
629 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
630 result, expected_result);
631 #else
632 abort();
633 #endif
635 /* int */
636 int_src1 = (vector int) {1, 2, 3, 4};
637 int_src2 = (vector int) {1, 20, 3, 4};
639 expected_result = 1;
641 result = vec_first_mismatch_index (int_src1, int_src2);
643 #ifdef DEBUG2
644 print_signed_int("src1", int_src1);
645 print_signed_int("src2", int_src2);
646 printf("vec_first_mismatch_index = %d\n\n", result);
647 #endif
649 if (result != expected_result)
650 #ifdef DEBUG
651 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
652 result, expected_result);
653 #else
654 abort();
655 #endif
657 int_src1 = (vector int) {1, 2, 3, 4};
658 int_src2 = (vector int) {1, 2, 3, 4};
660 expected_result = 4;
662 result = vec_first_mismatch_index (int_src1, int_src2);
664 #ifdef DEBUG2
665 print_signed_int("src1", int_src1);
666 print_signed_int("src2", int_src2);
667 printf("vec_first_mismatch_index = %d\n\n", result);
668 #endif
670 if (result != expected_result)
671 #ifdef DEBUG
672 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
673 result, expected_result);
674 #else
675 abort();
676 #endif
678 int_src1 = (vector int) {1, 0, 3, 4};
679 int_src2 = (vector int) {1, 2, 3, 4};
681 expected_result = 1;
683 result = vec_first_mismatch_index (int_src1, int_src2);
685 #ifdef DEBUG2
686 print_signed_int("src1", int_src1);
687 print_signed_int("src2", int_src2);
688 printf("vec_first_mismatch_index = %d\n\n", result);
689 #endif
691 if (result != expected_result)
692 #ifdef DEBUG
693 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
694 result, expected_result);
695 #else
696 abort();
697 #endif
699 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
700 uint_src2 = (vector unsigned int) {11, 2, 33, 4};
702 expected_result = 0;
704 result = vec_first_mismatch_index (uint_src1, uint_src2);
706 #ifdef DEBUG2
707 print_unsigned_int("src1", uint_src1);
708 print_unsigned_int("src2", uint_src2);
709 printf("vec_first_mismatch_index = %d\n\n", result);
710 #endif
712 if (result != expected_result)
713 #ifdef DEBUG
714 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
715 result, expected_result);
716 #else
717 abort();
718 #endif
720 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
721 uint_src2 = (vector unsigned int) {1, 2, 3, 4};
723 expected_result = 4;
725 result = vec_first_mismatch_index (uint_src1, uint_src2);
727 #ifdef DEBUG2
728 print_unsigned_int("src1", uint_src1);
729 print_unsigned_int("src2", uint_src2);
730 printf("vec_first_mismatch_index = %d\n\n", result);
731 #endif
733 if (result != expected_result)
735 #ifdef DEBUG
736 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
737 result, expected_result);
738 #else
739 abort();
740 #endif
742 /* Tests for: vec_first_match_or_eos_index()
743 The element index in BE order is returned for the first match
744 or the number of elements if there is no match. */
745 /* char */
746 char_src1 = (vector signed char) { 0x40, 0, 0x40, 0x40,
747 0x40, 0x40, 0x40, 0x40,
748 0x40, 0x40, 0x40, 0x40,
749 0x40, 0x40, 0x40, 0x40 };
751 char_src2 = (vector signed char) { 0x41, 0, 0x43, 0x44,
752 0x45, 0x46, 0x47, 0x40,
753 0x40, 0x40, 0x40, 0x40,
754 0x40, 0x40, 0x40, 0x40 };
755 expected_result = 1;
757 result = vec_first_match_or_eos_index (char_src1, char_src2);
759 #ifdef DEBUG2
760 print_signed_char("src1", char_src1);
761 print_signed_char("src2", char_src2);
762 printf("vec_first_match_or_eos_index = %d\n\n", result);
763 #endif
765 if (result != expected_result)
766 #ifdef DEBUG
767 printf("Error: char first match result (%d) does not match expected result (%d)\n",
768 result, expected_result);
769 #else
770 abort();
771 #endif
773 char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
774 9, 10, 11, 12, 13, 14, 15, 16};
775 char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
776 9, 10, 11, 12, 13, 14, 15, 16};
777 expected_result = 0;
779 result = vec_first_match_or_eos_index (char_src1, char_src2);
781 #ifdef DEBUG2
782 print_signed_char("src1", char_src1);
783 print_signed_char("src2", char_src2);
784 printf("vec_first_match_or_eos_index = %d\n\n", result);
785 #endif
787 if (result != expected_result)
788 #ifdef DEBUG
789 printf("Error: char first match result (%d) does not match expected result (%d)\n",
790 result, expected_result);
791 #else
792 abort();
793 #endif
795 char_src1 = (vector signed char) {-1, 2, 3, 0, -5, 6, 7, 8,
796 9, 10, 11, 12, 13, 14, 15, 16};
797 char_src2 = (vector signed char) {2, 3, 20, 0, -5, 6, 7, 8,
798 9, 10, 11, 12, 13, 14, 15, 16};
799 expected_result = 3;
801 result = vec_first_match_or_eos_index (char_src1, char_src2);
803 #ifdef DEBUG2
804 print_signed_char("src1", char_src1);
805 print_signed_char("src2", char_src2);
806 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
807 #endif
809 if (result != expected_result)
810 #ifdef DEBUG
811 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
812 result, expected_result);
813 #else
814 abort();
815 #endif
817 char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
818 9, 10, 11, 12, 13, 14, 15, 16};
819 char_src2 = (vector signed char) {-1, -2, -3, -4, -5, -6, -7, -8,
820 -9, -10, -11, -12, -13, -14, -15, -16};
821 expected_result = 16;
823 result = vec_first_match_or_eos_index (char_src1, char_src2);
825 #ifdef DEBUG2
826 print_signed_char("src1", char_src1);
827 print_signed_char("src2", char_src2);
828 printf("vec_first_match_or_eos_index = %d\n\n", result);
829 #endif
831 if (result != expected_result)
832 #ifdef DEBUG
833 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
834 result, expected_result);
835 #else
836 abort();
837 #endif
839 uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
840 9, 10, 11, 12, 13, 14, 15, 16};
841 uchar_src2 = (vector unsigned char) {-1, 0, -3, -4, -5, -6, -7, -8,
842 9, 10, 11, 12, 13, 14, 15, 16};
843 expected_result = 1;
845 result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
847 #ifdef DEBUG2
848 print_unsigned_char("src1", uchar_src1);
849 print_unsigned_char("src2", uchar_src2);
850 printf("vec_first_match_or_eos_index = %d\n\n", result);
851 #endif
853 if (result != expected_result)
854 #ifdef DEBUG
855 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
856 result, expected_result);
857 #else
858 abort();
859 #endif
861 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
862 10, 11, 12, 13, 14, 15, 16, 17};
863 uchar_src2 = (vector unsigned char) {3, 4, 5, 6, 7, 8, 9, 10,
864 11, 12, 13, 14, 15, 16, 17, 18};
865 expected_result = 16;
867 result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
869 #ifdef DEBUG2
870 print_unsigned_char("src1", uchar_src1);
871 print_unsigned_char("src2", uchar_src2);
872 printf("vec_first_match_or_eos_index = %d\n\n", result);
873 #endif
875 if (result != expected_result)
876 #ifdef DEBUG
877 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
878 result, expected_result);
879 #else
880 abort();
881 #endif
883 /* short int */
884 short_src1 = (vector short int) {10, -20, -30, 40, 50, 60, 70, 80};
885 short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
887 expected_result = 3;
889 result = vec_first_match_or_eos_index (short_src1, short_src2);
891 #ifdef DEBUG2
892 print_signed_short_int("src1", short_src1);
893 print_signed_short_int("src2", short_src2);
894 printf("vec_first_match_or_eos_index = %d\n\n", result);
895 #endif
897 if (result != expected_result)
898 #ifdef DEBUG
899 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
900 result, expected_result);
901 #else
902 abort();
903 #endif
905 short_src1 = (vector short int) {1, 20, 30, 40, 50, 60, 70, 80};
906 short_src2 = (vector short int) {10, 0, 30, 40, 50, 60, 70, 80};
908 expected_result = 1;
910 result = vec_first_match_or_eos_index (short_src1, short_src2);
912 #ifdef DEBUG2
913 print_signed_short_int("src1", short_src1);
914 print_signed_short_int("src2", short_src2);
915 printf("vec_first_match_or_eos_index = %d\n\n", result);
916 #endif
918 if (result != expected_result)
919 #ifdef DEBUG
920 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
921 result, expected_result);
922 #else
923 abort();
924 #endif
926 short_src1 = (vector short int) {-10, -20, -30, -40, -50, -60, -70, -80};
927 short_src2 = (vector short int) {10, 20, 30, 40, 50, 0, 70, 80};
929 expected_result = 5;
931 result = vec_first_match_or_eos_index (short_src1, short_src2);
933 #ifdef DEBUG2
934 print_signed_short_int("src1", short_src1);
935 print_signed_short_int("src2", short_src2);
936 printf("vec_first_match_or_eos_index = %d\n\n", result);
937 #endif
939 if (result != expected_result)
940 #ifdef DEBUG
941 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
942 result, expected_result);
943 #else
944 abort();
945 #endif
947 short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
948 short_src2 = (vector short int) {0, 0, 0, 0, 0, 0, 0, 0};
950 expected_result = 0;
952 result = vec_first_match_or_eos_index (short_src1, short_src2);
954 #ifdef DEBUG2
955 print_signed_short_int("src1", short_src1);
956 print_signed_short_int("src2", short_src2);
957 printf("vec_first_match_or_eos_index = %d\n\n", result);
958 #endif
960 if (result != expected_result)
961 #ifdef DEBUG
962 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
963 result, expected_result);
964 #else
965 abort();
966 #endif
968 ushort_src1 = (vector short unsigned int) {1, 2, 0, 0, 60, 70, 0};
969 ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
971 expected_result = 2;
973 result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
975 #ifdef DEBUG2
976 print_unsigned_short_int("src1", ushort_src1);
977 print_unsigned_short_int("src2", ushort_src2);
978 printf("vec_first_match_or_eos_index = %d\n\n", result);
979 #endif
981 if (result != expected_result)
982 #ifdef DEBUG
983 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
984 result, expected_result);
985 #else
986 abort();
987 #endif
989 ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
990 60, -70, 80, -90};
991 ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
992 -60, 70, -80, 90};
994 expected_result = 8;
996 result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
998 #ifdef DEBUG2
999 print_unsigned_short_int("src1", ushort_src1);
1000 print_unsigned_short_int("src2", ushort_src2);
1001 printf("vec_first_match_or_eos_index = %d\n\n", result);
1002 #endif
1004 if (result != expected_result)
1005 #ifdef DEBUG
1006 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
1007 result, expected_result);
1008 #else
1009 abort();
1010 #endif
1011 ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
1012 60, -70, 80, 0};
1013 ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
1014 -60, 70, -80, 90};
1016 expected_result = 7;
1018 result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
1020 #ifdef DEBUG2
1021 print_unsigned_short_int("src1", ushort_src1);
1022 print_unsigned_short_int("src2", ushort_src2);
1023 printf("vec_first_match_or_eos_index = %d\n\n", result);
1024 #endif
1026 if (result != expected_result)
1027 #ifdef DEBUG
1028 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
1029 result, expected_result);
1030 #else
1031 abort();
1032 #endif
1034 /* int */
1035 int_src1 = (vector int) {1, 2, 3, 4};
1036 int_src2 = (vector int) {10, 20, 30, 4};
1038 expected_result = 3;
1040 result = vec_first_match_or_eos_index (int_src1, int_src2);
1042 #ifdef DEBUG2
1043 print_signed_int("src1", int_src1);
1044 print_signed_int("src2", int_src2);
1045 printf("vec_first_match_or_eos_index = %d\n\n", result);
1046 #endif
1048 if (result != expected_result)
1049 #ifdef DEBUG
1050 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
1051 result, expected_result);
1052 #else
1053 abort();
1054 #endif
1056 int_src1 = (vector int) {0, 2, 3, 4};
1057 int_src2 = (vector int) {4, 3, 2, 1};
1059 expected_result = 0;
1061 result = vec_first_match_or_eos_index (int_src1, int_src2);
1063 #ifdef DEBUG2
1064 print_signed_int("src1", int_src1);
1065 print_signed_int("src2", int_src2);
1066 printf("vec_first_match_or_eos_index = %d\n\n", result);
1067 #endif
1069 if (result != expected_result)
1070 #ifdef DEBUG
1071 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
1072 result, expected_result);
1073 #else
1074 abort();
1075 #endif
1077 int_src1 = (vector int) {1, 2, 3, 4};
1078 int_src2 = (vector int) {4, 3, 2, 1};
1080 expected_result = 4;
1082 result = vec_first_match_or_eos_index (int_src1, int_src2);
1084 #ifdef DEBUG2
1085 print_signed_int("src1", int_src1);
1086 print_signed_int("src2", int_src2);
1087 printf("vec_first_match_or_eos_index = %d\n\n", result);
1088 #endif
1090 if (result != expected_result)
1091 #ifdef DEBUG
1092 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
1093 result, expected_result);
1094 #else
1095 abort();
1096 #endif
1098 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
1099 uint_src2 = (vector unsigned int) {11, 2, 33, 4};
1101 expected_result = 1;
1103 result = vec_first_match_or_eos_index (uint_src1, uint_src2);
1105 #ifdef DEBUG2
1106 print_unsigned_int("src1", uint_src1);
1107 print_unsigned_int("src2", uint_src2);
1108 printf("vec_first_match_or_eos_index = %d\n\n", result);
1109 #endif
1111 if (result != expected_result)
1112 #ifdef DEBUG
1113 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1114 result, expected_result);
1115 #else
1116 abort();
1117 #endif
1119 uint_src1 = (vector unsigned int) {1, 2, 0, 4};
1120 uint_src2 = (vector unsigned int) {2, 3, 4, 5};
1122 expected_result = 2;
1124 result = vec_first_match_or_eos_index (uint_src1, uint_src2);
1126 #ifdef DEBUG2
1127 print_unsigned_int("src1", uint_src1);
1128 print_unsigned_int("src2", uint_src2);
1129 printf("vec_first_match_or_eos_index = %d\n\n", result);
1130 #endif
1132 if (result != expected_result)
1133 #ifdef DEBUG
1134 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1135 result, expected_result);
1136 #else
1137 abort();
1138 #endif
1140 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
1141 uint_src2 = (vector unsigned int) {2, 3, 4, 5};
1143 expected_result = 4;
1145 result = vec_first_match_or_eos_index (uint_src1, uint_src2);
1147 #ifdef DEBUG2
1148 print_unsigned_int("src1", uint_src1);
1149 print_unsigned_int("src2", uint_src2);
1150 printf("vec_first_match_or_eos_index = %d\n\n", result);
1151 #endif
1153 if (result != expected_result)
1154 #ifdef DEBUG
1155 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1156 result, expected_result);
1157 #else
1158 abort();
1159 #endif
1161 /* Tests for: vec_first_mismatch_or_eos_index()
1162 The element index in BE order is returned for the first mismatch
1163 or the number of elements if there is no match. */
1164 /* char */
1165 char_src1 = (vector signed char) {1, 2, 0, 4, -5, 6, 7, 8,
1166 9, 10, 11, 12, 13, 14, 15, 16};
1167 char_src2 = (vector signed char) {1, 2, 0, 20, -5, 6, 7, 8,
1168 9, 10, 11, 12, 13, 14, 15, 16};
1169 expected_result = 2;
1171 result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
1173 #ifdef DEBUG2
1174 print_signed_char("src1", char_src1);
1175 print_signed_char("src2", char_src2);
1176 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1177 #endif
1179 if (result != expected_result)
1180 #ifdef DEBUG
1181 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1182 result, expected_result);
1183 #else
1184 abort();
1185 #endif
1187 char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
1188 9, 10, 11, 12, 13, 14, 15, 16};
1189 char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
1190 9, 10, 11, 12, 13, 14, 15, 16};
1191 expected_result = 3;
1193 result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
1195 #ifdef DEBUG2
1196 print_signed_char("src1", char_src1);
1197 print_signed_char("src2", char_src2);
1198 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1199 #endif
1201 if (result != expected_result)
1202 #ifdef DEBUG
1203 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1204 result, expected_result);
1205 #else
1206 abort();
1207 #endif
1209 char_src1 = (vector signed char) {1, 2, 0, 4, 5, 6, 7, 8,
1210 9, 10, 11, 12, 13, 14, 15, 16};
1211 char_src2 = (vector signed char) {1, 2, 0, 4, 5, 6, 7, 8,
1212 9, 10, 11, 12, 13, 14, 15, 16};
1213 expected_result = 2;
1215 result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
1217 #ifdef DEBUG2
1218 print_signed_char("src1", char_src1);
1219 print_signed_char("src2", char_src2);
1220 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1221 #endif
1223 if (result != expected_result)
1224 #ifdef DEBUG
1225 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1226 result, expected_result);
1227 #else
1228 abort();
1229 #endif
1231 char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
1232 9, 10, 11, 12, 13, 14, 15, 16};
1233 char_src2 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
1234 9, 10, 11, 12, 13, 14, 15, 16};
1235 expected_result = 16;
1237 result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
1239 #ifdef DEBUG2
1240 print_signed_char("src1", char_src1);
1241 print_signed_char("src2", char_src2);
1242 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1243 #endif
1245 if (result != expected_result)
1246 #ifdef DEBUG
1247 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1248 result, expected_result);
1249 #else
1250 abort();
1251 #endif
1253 uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
1254 9, 10, 11, 12, 13, 14, 15, 16};
1255 uchar_src2 = (vector unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
1256 9, 10, 11, 12, 13, 14, 15, 16};
1257 expected_result = 1;
1259 result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
1261 #ifdef DEBUG2
1262 print_unsigned_char("src1", uchar_src1);
1263 print_unsigned_char("src2", uchar_src2);
1264 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1265 #endif
1267 if (result != expected_result)
1268 #ifdef DEBUG
1269 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1270 result, expected_result);
1271 #else
1272 abort();
1273 #endif
1275 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1276 0, 11, 12, 13, 14, 15, 16};
1277 uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1278 0, 11, 12, 13, 14, 15, 16};
1279 expected_result = 8;
1281 result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
1283 #ifdef DEBUG2
1284 print_unsigned_char("src1", uchar_src1);
1285 print_unsigned_char("src2", uchar_src2);
1286 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1287 #endif
1289 if (result != expected_result)
1290 #ifdef DEBUG
1291 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1292 result, expected_result);
1293 #else
1294 abort();
1295 #endif
1297 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1298 10, 11, 12, 13, 14, 15, 16, 17};
1299 uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1300 10, 11, 12, 13, 14, 0, 16, 17};
1301 expected_result = 13;
1303 result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
1305 #ifdef DEBUG2
1306 print_unsigned_char("src1", uchar_src1);
1307 print_unsigned_char("src2", uchar_src2);
1308 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1309 #endif
1311 if (result != expected_result)
1312 #ifdef DEBUG
1313 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1314 result, expected_result);
1315 #else
1316 abort();
1317 #endif
1319 uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1320 10, 11, 12, 13, 14, 15, 16, 17};
1321 uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1322 10, 11, 12, 13, 14, 15, 16, 17};
1323 expected_result = 16;
1325 result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
1327 #ifdef DEBUG2
1328 print_unsigned_char("src1", uchar_src1);
1329 print_unsigned_char("src2", uchar_src2);
1330 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1331 #endif
1333 if (result != expected_result)
1334 #ifdef DEBUG
1335 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1336 result, expected_result);
1337 #else
1338 abort();
1339 #endif
1341 /* short int */
1342 short_src1 = (vector short int) {-10, -20, 30, 40, 50, 60, 70, 80};
1343 short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
1345 expected_result = 1;
1347 result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
1349 #ifdef DEBUG2
1350 print_signed_short_int("src1", short_src1);
1351 print_signed_short_int("src2", short_src2);
1352 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1353 #endif
1355 if (result != expected_result)
1356 #ifdef DEBUG
1357 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1358 result, expected_result);
1359 #else
1360 abort();
1361 #endif
1363 short_src1 = (vector short int) {0, 20, 30, 40, 50, 60, 70, 80};
1364 short_src2 = (vector short int) {0, 20, 30, 40, 50, 60, 70, 80};
1366 expected_result = 0;
1368 result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
1370 #ifdef DEBUG2
1371 print_signed_short_int("src1", short_src1);
1372 print_signed_short_int("src2", short_src2);
1373 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1374 #endif
1376 if (result != expected_result)
1377 #ifdef DEBUG
1378 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1379 result, expected_result);
1380 #else
1381 abort();
1382 #endif
1384 short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
1385 short_src2 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
1387 expected_result = 8;
1389 result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
1391 #ifdef DEBUG2
1392 print_signed_short_int("src1", short_src1);
1393 print_signed_short_int("src2", short_src2);
1394 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1395 #endif
1397 if (result != expected_result)
1398 #ifdef DEBUG
1399 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1400 result, expected_result);
1401 #else
1402 abort();
1403 #endif
1405 short_src1 = (vector short int) {10, 0, 30, 40, 50, 60, 70, 80};
1406 short_src2 = (vector short int) {10, 0, 30, 40, 50, 60, 70, 80};
1408 expected_result = 1;
1410 result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
1412 #ifdef DEBUG2
1413 print_signed_short_int("src1", short_src1);
1414 print_signed_short_int("src2", short_src2);
1415 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1416 #endif
1418 if (result != expected_result)
1419 #ifdef DEBUG
1420 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1421 result, expected_result);
1422 #else
1423 abort();
1424 #endif
1426 ushort_src1 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 0};
1427 ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
1429 expected_result = 7;
1431 result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
1433 #ifdef DEBUG2
1434 print_unsigned_short_int("src1", ushort_src1);
1435 print_unsigned_short_int("src2", ushort_src2);
1436 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1437 #endif
1439 if (result != expected_result)
1440 #ifdef DEBUG
1441 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1442 result, expected_result);
1443 #else
1444 abort();
1445 #endif
1447 ushort_src1 = (vector short unsigned int) {20, 0, 40, 50, 60, 70, 80, 90};
1448 ushort_src2 = (vector short unsigned int) {20, 0, 40, 50, 60, 70, 80, 90};
1450 expected_result = 1;
1452 result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
1454 #ifdef DEBUG2
1455 print_unsigned_short_int("src1", ushort_src1);
1456 print_unsigned_short_int("src2", ushort_src2);
1457 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1458 #endif
1460 if (result != expected_result)
1461 #ifdef DEBUG
1462 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1463 result, expected_result);
1464 #else
1465 abort();
1466 #endif
1468 ushort_src1 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
1469 ushort_src2 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
1471 expected_result = 8;
1473 result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
1475 #ifdef DEBUG2
1476 print_unsigned_short_int("src1", ushort_src1);
1477 print_unsigned_short_int("src2", ushort_src2);
1478 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1479 #endif
1481 if (result != expected_result)
1482 #ifdef DEBUG
1483 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1484 result, expected_result);
1485 #else
1486 abort();
1487 #endif
1489 /* int */
1490 int_src1 = (vector int) {1, 2, 3, 4};
1491 int_src2 = (vector int) {1, 20, 3, 4};
1493 expected_result = 1;
1495 result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
1497 #ifdef DEBUG2
1498 print_signed_int("src1", int_src1);
1499 print_signed_int("src2", int_src2);
1500 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1501 #endif
1503 if (result != expected_result)
1504 #ifdef DEBUG
1505 printf("Error: int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1506 result, expected_result);
1507 #else
1508 abort();
1509 #endif
1511 int_src1 = (vector int) {1, 2, 3, 4};
1512 int_src2 = (vector int) {1, 2, 3, 4};
1514 expected_result = 4;
1516 result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
1518 #ifdef DEBUG2
1519 print_signed_int("src1", int_src1);
1520 print_signed_int("src2", int_src2);
1521 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1522 #endif
1524 if (result != expected_result)
1525 #ifdef DEBUG
1526 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1527 result, expected_result);
1528 #else
1529 abort();
1530 #endif
1532 int_src1 = (vector int) {1, 2, 0, 4};
1533 int_src2 = (vector int) {1, 2, 0, 4};
1535 expected_result = 2;
1537 result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
1539 #ifdef DEBUG2
1540 print_signed_int("src1", int_src1);
1541 print_signed_int("src2", int_src2);
1542 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1543 #endif
1545 if (result != expected_result)
1546 #ifdef DEBUG
1547 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1548 result, expected_result);
1549 #else
1550 abort();
1551 #endif
1553 int_src1 = (vector int) {1, 0, 3, 4};
1554 int_src2 = (vector int) {1, 2, 3, 4};
1556 expected_result = 1;
1558 result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
1560 #ifdef DEBUG2
1561 print_signed_int("src1", int_src1);
1562 print_signed_int("src2", int_src2);
1563 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1564 #endif
1565 if (result != expected_result)
1566 #ifdef DEBUG
1567 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1568 result, expected_result);
1569 #else
1570 abort();
1571 #endif
1573 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
1574 uint_src2 = (vector unsigned int) {11, 2, 33, 4};
1576 expected_result = 0;
1578 result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
1580 #ifdef DEBUG2
1581 print_unsigned_int("src1", uint_src1);
1582 print_unsigned_int("src2", uint_src2);
1583 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1584 #endif
1585 if (result != expected_result)
1586 #ifdef DEBUG
1587 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1588 result, expected_result);
1589 #else
1590 abort();
1591 #endif
1593 uint_src1 = (vector unsigned int) {1, 2, 3, 0};
1594 uint_src2 = (vector unsigned int) {1, 2, 3, 0};
1596 expected_result = 3;
1598 result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
1600 #ifdef DEBUG2
1601 print_unsigned_int("src1", uint_src1);
1602 print_unsigned_int("src2", uint_src2);
1603 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1604 #endif
1606 if (result != expected_result)
1607 #ifdef DEBUG
1608 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1609 result, expected_result);
1610 #else
1611 abort();
1612 #endif
1614 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
1615 uint_src2 = (vector unsigned int) {1, 2, 3, 4};
1617 expected_result = 4;
1619 result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
1621 #ifdef DEBUG2
1622 print_unsigned_int("src1", uint_src1);
1623 print_unsigned_int("src2", uint_src2);
1624 printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
1625 #endif
1627 if (result != expected_result)
1628 #ifdef DEBUG
1629 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1630 result, expected_result);
1631 #else
1632 abort();
1633 #endif