2 /* { dg-require-effective-target p9vector_hw } */
3 /* { dg-options "-mdejagnu-cpu=power9 -O2" } */
7 #include <altivec.h> // vector
21 void print_signed_char (char *name
, vector
signed char src
)
25 for (i
= 0; i
< 8; i
++)
26 printf("%s[%d] = %d, ", name
, i
, src
[i
]);
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
)
40 for (i
= 0; i
< 8; i
++)
41 printf("%s[%d] = %d, ", name
, i
, src
[i
]);
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
)
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
)
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
)
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
)
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
]);
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. */
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};
116 result
= vec_first_match_index (char_src1
, char_src2
);
119 print_signed_char("src1", char_src1
);
120 print_signed_char("src2", char_src2
);
121 printf(" vec_first_match_index = %d\n\n", result
);
124 if (result
!= expected_result
)
126 printf("Error: char first match result (%d) does not match expected result (%d)\n",
127 result
, expected_result
);
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};
138 result
= vec_first_match_index (char_src1
, char_src2
);
141 print_signed_char("src1", char_src1
);
142 print_signed_char("src2", char_src2
);
143 printf(" vec_first_match_index = %d\n\n", result
);
146 if (result
!= expected_result
)
148 printf("Error: char first match result (%d) does not match expected result (%d)\n",
149 result
, expected_result
);
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
);
163 print_signed_char("src1", char_src1
);
164 print_signed_char("src2", char_src2
);
165 printf("vec_first_match_index = %d\n\n", result
);
168 if (result
!= expected_result
)
170 printf("Error: char first match result (%d) does not match expected result (%d)\n",
171 result
, expected_result
);
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};
182 result
= vec_first_match_index (uchar_src1
, uchar_src2
);
185 print_unsigned_char("src1", uchar_src1
);
186 print_unsigned_char("src2", uchar_src2
);
187 printf("vec_first_match_index = %d\n\n", result
);
190 if (result
!= expected_result
)
192 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
193 result
, expected_result
);
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
);
207 print_unsigned_char("src1", uchar_src1
);
208 print_unsigned_char("src2", uchar_src2
);
209 printf("vec_first_match_index = %d\n\n", result
);
212 if (result
!= expected_result
)
214 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
215 result
, expected_result
);
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};
226 result
= vec_first_match_index (short_src1
, short_src2
);
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
);
234 if (result
!= expected_result
)
236 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
237 result
, expected_result
);
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};
247 result
= vec_first_match_index (short_src1
, short_src2
);
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
);
255 if (result
!= expected_result
)
257 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
258 result
, expected_result
);
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};
268 result
= vec_first_match_index (ushort_src1
, ushort_src2
);
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
);
276 if (result
!= expected_result
)
278 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
279 result
, expected_result
);
284 ushort_src1
= (vector
short unsigned int) {-20, 30, -40, 50,
286 ushort_src2
= (vector
short unsigned int) {20, -30, 40, -50,
291 result
= vec_first_match_index (ushort_src1
, ushort_src2
);
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
);
299 if (result
!= expected_result
)
301 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
302 result
, expected_result
);
308 int_src1
= (vector
int) {1, 2, 3, 4};
309 int_src2
= (vector
int) {10, 20, 30, 4};
313 result
= vec_first_match_index (int_src1
, int_src2
);
316 print_signed_int("src1", int_src1
);
317 print_signed_int("src2", int_src2
);
318 printf("vec_first_match_index = %d\n\n", result
);
321 if (result
!= expected_result
)
323 printf("Error: int first match result (%d) does not match expected result (%d)\n",
324 result
, expected_result
);
329 int_src1
= (vector
int) {1, 2, 3, 4};
330 int_src2
= (vector
int) {4, 3, 2, 1};
334 result
= vec_first_match_index (int_src1
, int_src2
);
337 print_signed_int("src1", int_src1
);
338 print_signed_int("src2", int_src2
);
339 printf("vec_first_match_index = %d\n\n", result
);
342 if (result
!= expected_result
)
344 printf("Error: int first match result (%d) does not match expected result (%d)\n",
345 result
, expected_result
);
350 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
351 uint_src2
= (vector
unsigned int) {11, 2, 33, 4};
355 result
= vec_first_match_index (uint_src1
, uint_src2
);
358 print_unsigned_int("src1", uint_src1
);
359 print_unsigned_int("src2", uint_src2
);
360 printf("vec_first_match_index = %d\n\n", result
);
363 if (result
!= expected_result
)
365 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
366 result
, expected_result
);
371 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
372 uint_src2
= (vector
unsigned int) {2, 3, 4, 5};
376 result
= vec_first_match_index (uint_src1
, uint_src2
);
379 print_unsigned_int("src1", uint_src1
);
380 print_unsigned_int("src2", uint_src2
);
381 printf("vec_first_match_index = %d\n\n", result
);
384 if (result
!= expected_result
)
386 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
387 result
, expected_result
);
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. */
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};
402 result
= vec_first_mismatch_index (char_src1
, char_src2
);
405 print_signed_char("src1", char_src1
);
406 print_signed_char("src2", char_src2
);
407 printf("vec_first_mismatch_index = %d\n\n", result
);
410 if (result
!= expected_result
)
412 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
413 result
, expected_result
);
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};
424 result
= vec_first_mismatch_index (char_src1
, char_src2
);
427 print_signed_char("src1", char_src1
);
428 print_signed_char("src2", char_src2
);
429 printf("vec_first_mismatch_index = %d\n\n", result
);
432 if (result
!= expected_result
)
434 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
435 result
, expected_result
);
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};
446 result
= vec_first_mismatch_index (char_src1
, char_src2
);
449 print_signed_char("src1", char_src1
);
450 print_signed_char("src2", char_src2
);
451 printf("vec_first_mismatch_index = %d\n\n", result
);
454 if (result
!= expected_result
)
456 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
457 result
, expected_result
);
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
);
471 print_signed_char("src1", char_src1
);
472 print_signed_char("src2", char_src2
);
473 printf("vec_first_mismatch_index = %d\n\n", result
);
476 if (result
!= expected_result
)
478 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
479 result
, expected_result
);
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};
490 result
= vec_first_mismatch_index (uchar_src1
, uchar_src2
);
493 print_unsigned_char("src1", uchar_src1
);
494 print_unsigned_char("src2", uchar_src2
);
495 printf("vec_first_mismatch_index = %d\n\n", result
);
498 if (result
!= expected_result
)
500 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
501 result
, expected_result
);
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};
512 result
= vec_first_mismatch_index (uchar_src1
, uchar_src2
);
515 print_unsigned_char("src1", uchar_src1
);
516 print_unsigned_char("src2", uchar_src2
);
517 printf("vec_first_mismatch_index = %d\n\n", result
);
520 if (result
!= expected_result
)
522 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
523 result
, expected_result
);
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
);
537 print_unsigned_char("src1", uchar_src1
);
538 print_unsigned_char("src2", uchar_src2
);
539 printf("vec_first_mismatch_index = %d\n\n", result
);
542 if (result
!= expected_result
)
544 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
545 result
, expected_result
);
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};
556 result
= vec_first_mismatch_index (short_src1
, short_src2
);
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
);
564 if (result
!= expected_result
)
566 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
567 result
, expected_result
);
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};
577 result
= vec_first_mismatch_index (short_src1
, short_src2
);
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
);
585 if (result
!= expected_result
)
587 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
588 result
, expected_result
);
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};
598 result
= vec_first_mismatch_index (ushort_src1
, ushort_src2
);
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
);
606 if (result
!= expected_result
)
608 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
609 result
, expected_result
);
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};
619 result
= vec_first_mismatch_index (ushort_src1
, ushort_src2
);
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
);
627 if (result
!= expected_result
)
629 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
630 result
, expected_result
);
636 int_src1
= (vector
int) {1, 2, 3, 4};
637 int_src2
= (vector
int) {1, 20, 3, 4};
641 result
= vec_first_mismatch_index (int_src1
, int_src2
);
644 print_signed_int("src1", int_src1
);
645 print_signed_int("src2", int_src2
);
646 printf("vec_first_mismatch_index = %d\n\n", result
);
649 if (result
!= expected_result
)
651 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
652 result
, expected_result
);
657 int_src1
= (vector
int) {1, 2, 3, 4};
658 int_src2
= (vector
int) {1, 2, 3, 4};
662 result
= vec_first_mismatch_index (int_src1
, int_src2
);
665 print_signed_int("src1", int_src1
);
666 print_signed_int("src2", int_src2
);
667 printf("vec_first_mismatch_index = %d\n\n", result
);
670 if (result
!= expected_result
)
672 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
673 result
, expected_result
);
678 int_src1
= (vector
int) {1, 0, 3, 4};
679 int_src2
= (vector
int) {1, 2, 3, 4};
683 result
= vec_first_mismatch_index (int_src1
, int_src2
);
686 print_signed_int("src1", int_src1
);
687 print_signed_int("src2", int_src2
);
688 printf("vec_first_mismatch_index = %d\n\n", result
);
691 if (result
!= expected_result
)
693 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
694 result
, expected_result
);
699 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
700 uint_src2
= (vector
unsigned int) {11, 2, 33, 4};
704 result
= vec_first_mismatch_index (uint_src1
, uint_src2
);
707 print_unsigned_int("src1", uint_src1
);
708 print_unsigned_int("src2", uint_src2
);
709 printf("vec_first_mismatch_index = %d\n\n", result
);
712 if (result
!= expected_result
)
714 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
715 result
, expected_result
);
720 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
721 uint_src2
= (vector
unsigned int) {1, 2, 3, 4};
725 result
= vec_first_mismatch_index (uint_src1
, uint_src2
);
728 print_unsigned_int("src1", uint_src1
);
729 print_unsigned_int("src2", uint_src2
);
730 printf("vec_first_mismatch_index = %d\n\n", result
);
733 if (result
!= expected_result
)
736 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
737 result
, expected_result
);
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. */
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 };
757 result
= vec_first_match_or_eos_index (char_src1
, char_src2
);
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
);
765 if (result
!= expected_result
)
767 printf("Error: char first match result (%d) does not match expected result (%d)\n",
768 result
, expected_result
);
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};
779 result
= vec_first_match_or_eos_index (char_src1
, char_src2
);
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
);
787 if (result
!= expected_result
)
789 printf("Error: char first match result (%d) does not match expected result (%d)\n",
790 result
, expected_result
);
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};
801 result
= vec_first_match_or_eos_index (char_src1
, char_src2
);
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
);
809 if (result
!= expected_result
)
811 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
812 result
, expected_result
);
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
);
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
);
831 if (result
!= expected_result
)
833 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
834 result
, expected_result
);
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};
845 result
= vec_first_match_or_eos_index (uchar_src1
, uchar_src2
);
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
);
853 if (result
!= expected_result
)
855 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
856 result
, expected_result
);
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
);
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
);
875 if (result
!= expected_result
)
877 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
878 result
, expected_result
);
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};
889 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
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
);
897 if (result
!= expected_result
)
899 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
900 result
, expected_result
);
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};
910 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
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
);
918 if (result
!= expected_result
)
920 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
921 result
, expected_result
);
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};
931 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
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
);
939 if (result
!= expected_result
)
941 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
942 result
, expected_result
);
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};
952 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
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
);
960 if (result
!= expected_result
)
962 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
963 result
, expected_result
);
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};
973 result
= vec_first_match_or_eos_index (ushort_src1
, ushort_src2
);
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
);
981 if (result
!= expected_result
)
983 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
984 result
, expected_result
);
989 ushort_src1
= (vector
short unsigned int) {-20, 30, -40, 50,
991 ushort_src2
= (vector
short unsigned int) {20, -30, 40, -50,
996 result
= vec_first_match_or_eos_index (ushort_src1
, ushort_src2
);
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
);
1004 if (result
!= expected_result
)
1006 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
1007 result
, expected_result
);
1011 ushort_src1
= (vector
short unsigned int) {-20, 30, -40, 50,
1013 ushort_src2
= (vector
short unsigned int) {20, -30, 40, -50,
1016 expected_result
= 7;
1018 result
= vec_first_match_or_eos_index (ushort_src1
, ushort_src2
);
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
);
1026 if (result
!= expected_result
)
1028 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
1029 result
, expected_result
);
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
);
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
);
1048 if (result
!= expected_result
)
1050 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
1051 result
, expected_result
);
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
);
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
);
1069 if (result
!= expected_result
)
1071 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
1072 result
, expected_result
);
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
);
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
);
1090 if (result
!= expected_result
)
1092 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
1093 result
, expected_result
);
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
);
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
);
1111 if (result
!= expected_result
)
1113 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1114 result
, expected_result
);
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
);
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
);
1132 if (result
!= expected_result
)
1134 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1135 result
, expected_result
);
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
);
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
);
1153 if (result
!= expected_result
)
1155 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1156 result
, expected_result
);
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. */
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
);
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
);
1179 if (result
!= expected_result
)
1181 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1182 result
, expected_result
);
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
);
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
);
1201 if (result
!= expected_result
)
1203 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1204 result
, expected_result
);
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
);
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
);
1223 if (result
!= expected_result
)
1225 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1226 result
, expected_result
);
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
);
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
);
1245 if (result
!= expected_result
)
1247 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1248 result
, expected_result
);
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
);
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
);
1267 if (result
!= expected_result
)
1269 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1270 result
, expected_result
);
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
);
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
);
1289 if (result
!= expected_result
)
1291 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1292 result
, expected_result
);
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
);
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
);
1311 if (result
!= expected_result
)
1313 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1314 result
, expected_result
);
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
);
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
);
1333 if (result
!= expected_result
)
1335 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1336 result
, expected_result
);
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
);
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
);
1355 if (result
!= expected_result
)
1357 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1358 result
, expected_result
);
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
);
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
);
1376 if (result
!= expected_result
)
1378 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1379 result
, expected_result
);
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
);
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
);
1397 if (result
!= expected_result
)
1399 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1400 result
, expected_result
);
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
);
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
);
1418 if (result
!= expected_result
)
1420 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1421 result
, expected_result
);
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
);
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
);
1439 if (result
!= expected_result
)
1441 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1442 result
, expected_result
);
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
);
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
);
1460 if (result
!= expected_result
)
1462 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1463 result
, expected_result
);
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
);
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
);
1481 if (result
!= expected_result
)
1483 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1484 result
, expected_result
);
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
);
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
);
1503 if (result
!= expected_result
)
1505 printf("Error: int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1506 result
, expected_result
);
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
);
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
);
1524 if (result
!= expected_result
)
1526 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1527 result
, expected_result
);
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
);
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
);
1545 if (result
!= expected_result
)
1547 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1548 result
, expected_result
);
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
);
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
);
1565 if (result
!= expected_result
)
1567 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1568 result
, expected_result
);
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
);
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
);
1585 if (result
!= expected_result
)
1587 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1588 result
, expected_result
);
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
);
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
);
1606 if (result
!= expected_result
)
1608 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1609 result
, expected_result
);
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
);
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
);
1627 if (result
!= expected_result
)
1629 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1630 result
, expected_result
);