1 /* { dg-do run { target { powerpc*-*-* && p9vector_hw } } } */
2 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
3 /* { dg-options "-mcpu=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) {-1, 2, 3, 4, -5, 6, 7, 8,
108 9, 10, 11, 12, 13, 14, 15, 16};
109 char_src2
= (vector
signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
110 9, 10, 11, 12, 13, 14, 15, 16};
113 result
= vec_first_match_index (char_src1
, char_src2
);
116 print_signed_char("src1", char_src1
);
117 print_signed_char("src2", char_src2
);
118 printf(" vec_first_match_index = %d\n\n", result
);
121 if (result
!= expected_result
)
123 printf("Error: char first match result (%d) does not match expected result (%d)\n",
124 result
, expected_result
);
129 char_src1
= (vector
signed char) {1, 2, 3, 4, 5, 6, 7, 8,
130 9, 10, 11, 12, 13, 14, 15, 16};
131 char_src2
= (vector
signed char) {-1, -2, -3, -4, -5, -6, -7, -8,
132 -9, -10, -11, -12, -13, -14, -15, -16};
133 expected_result
= 16;
135 result
= vec_first_match_index (char_src1
, char_src2
);
138 print_signed_char("src1", char_src1
);
139 print_signed_char("src2", char_src2
);
140 printf("vec_first_match_index = %d\n\n", result
);
143 if (result
!= expected_result
)
145 printf("Error: char first match result (%d) does not match expected result (%d)\n",
146 result
, expected_result
);
151 uchar_src1
= (vector
unsigned char) {0, 2, 3, 4, 5, 6, 7, 8,
152 9, 10, 11, 12, 13, 14, 15, 16};
153 uchar_src2
= (vector
unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
154 9, 10, 11, 12, 13, 14, 15, 16};
157 result
= vec_first_match_index (uchar_src1
, uchar_src2
);
160 print_unsigned_char("src1", uchar_src1
);
161 print_unsigned_char("src2", uchar_src2
);
162 printf("vec_first_match_index = %d\n\n", result
);
165 if (result
!= expected_result
)
167 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
168 result
, expected_result
);
173 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
174 10, 11, 12, 13, 14, 15, 16, 17};
175 uchar_src2
= (vector
unsigned char) {3, 4, 5, 6, 7, 8, 9, 10,
176 11, 12, 13, 14, 15, 16, 17, 18};
177 expected_result
= 16;
179 result
= vec_first_match_index (uchar_src1
, uchar_src2
);
182 print_unsigned_char("src1", uchar_src1
);
183 print_unsigned_char("src2", uchar_src2
);
184 printf("vec_first_match_index = %d\n\n", result
);
187 if (result
!= expected_result
)
189 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
190 result
, expected_result
);
196 short_src1
= (vector
short int) {10, -20, -30, 40, 50, 60, 70, 80};
197 short_src2
= (vector
short int) {-10, 20, 30, 40, 50, 60, 70, 80};
201 result
= vec_first_match_index (short_src1
, short_src2
);
204 print_signed_short_int("src1", short_src1
);
205 print_signed_short_int("src2", short_src2
);
206 printf("vec_first_match_index = %d\n\n", result
);
209 if (result
!= expected_result
)
211 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
212 result
, expected_result
);
217 short_src1
= (vector
short int) {10, 20, 30, 40, 50, 60, 70, 80};
218 short_src2
= (vector
short int) {0, 0, 0, 0, 0, 0, 0, 0};
222 result
= vec_first_match_index (short_src1
, short_src2
);
225 print_signed_short_int("src1", short_src1
);
226 print_signed_short_int("src2", short_src2
);
227 printf("vec_first_match_index = %d\n\n", result
);
230 if (result
!= expected_result
)
232 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
233 result
, expected_result
);
238 ushort_src1
= (vector
short unsigned int) {0, 0, 0, 0, 0, 60, 70, 0};
239 ushort_src2
= (vector
short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
243 result
= vec_first_match_index (ushort_src1
, ushort_src2
);
246 print_unsigned_short_int("src1", ushort_src1
);
247 print_unsigned_short_int("src2", ushort_src2
);
248 printf("vec_first_match_index = %d\n\n", result
);
251 if (result
!= expected_result
)
253 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
254 result
, expected_result
);
259 ushort_src1
= (vector
short unsigned int) {-20, 30, -40, 50,
261 ushort_src2
= (vector
short unsigned int) {20, -30, 40, -50,
266 result
= vec_first_match_index (ushort_src1
, ushort_src2
);
269 print_unsigned_short_int("src1", ushort_src1
);
270 print_unsigned_short_int("src2", ushort_src2
);
271 printf("vec_first_match_index = %d\n\n", result
);
274 if (result
!= expected_result
)
276 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
277 result
, expected_result
);
283 int_src1
= (vector
int) {1, 2, 3, 4};
284 int_src2
= (vector
int) {10, 20, 30, 4};
288 result
= vec_first_match_index (int_src1
, int_src2
);
291 print_signed_int("src1", int_src1
);
292 print_signed_int("src2", int_src2
);
293 printf("vec_first_match_index = %d\n\n", result
);
296 if (result
!= expected_result
)
298 printf("Error: int first match result (%d) does not match expected result (%d)\n",
299 result
, expected_result
);
304 int_src1
= (vector
int) {1, 2, 3, 4};
305 int_src2
= (vector
int) {4, 3, 2, 1};
309 result
= vec_first_match_index (int_src1
, int_src2
);
312 print_signed_int("src1", int_src1
);
313 print_signed_int("src2", int_src2
);
314 printf("vec_first_match_index = %d\n\n", result
);
317 if (result
!= expected_result
)
319 printf("Error: int first match result (%d) does not match expected result (%d)\n",
320 result
, expected_result
);
325 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
326 uint_src2
= (vector
unsigned int) {11, 2, 33, 4};
330 result
= vec_first_match_index (uint_src1
, uint_src2
);
333 print_unsigned_int("src1", uint_src1
);
334 print_unsigned_int("src2", uint_src2
);
335 printf("vec_first_match_index = %d\n\n", result
);
338 if (result
!= expected_result
)
340 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
341 result
, expected_result
);
346 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
347 uint_src2
= (vector
unsigned int) {2, 3, 4, 5};
351 result
= vec_first_match_index (uint_src1
, uint_src2
);
354 print_unsigned_int("src1", uint_src1
);
355 print_unsigned_int("src2", uint_src2
);
356 printf("vec_first_match_index = %d\n\n", result
);
359 if (result
!= expected_result
)
361 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
362 result
, expected_result
);
367 /* Tests for: vec_first_mismatch_index()
368 The element index in BE order is returned for the first mismatch
369 or the number of elements if there is no match. */
371 char_src1
= (vector
signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
372 9, 10, 11, 12, 13, 14, 15, 16};
373 char_src2
= (vector
signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
374 9, 10, 11, 12, 13, 14, 15, 16};
377 result
= vec_first_mismatch_index (char_src1
, char_src2
);
380 print_signed_char("src1", char_src1
);
381 print_signed_char("src2", char_src2
);
382 printf("vec_first_mismatch_index = %d\n\n", result
);
385 if (result
!= expected_result
)
387 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
388 result
, expected_result
);
393 char_src1
= (vector
signed char) {1, 2, 3, 4, 5, 6, 7, 8,
394 9, 10, 11, 12, 13, 14, 15, 16};
395 char_src2
= (vector
signed char) {1, 2, 3, 4, 5, 6, 7, 8,
396 9, 10, 11, 12, 13, 14, 15, 16};
397 expected_result
= 16;
399 result
= vec_first_mismatch_index (char_src1
, char_src2
);
402 print_signed_char("src1", char_src1
);
403 print_signed_char("src2", char_src2
);
404 printf("vec_first_mismatch_index = %d\n\n", result
);
407 if (result
!= expected_result
)
409 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
410 result
, expected_result
);
415 uchar_src1
= (vector
unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
416 9, 10, 11, 12, 13, 14, 15, 16};
417 uchar_src2
= (vector
unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
418 9, 10, 11, 12, 13, 14, 15, 16};
421 result
= vec_first_mismatch_index (uchar_src1
, uchar_src2
);
424 print_unsigned_char("src1", uchar_src1
);
425 print_unsigned_char("src2", uchar_src2
);
426 printf("vec_first_mismatch_index = %d\n\n", result
);
429 if (result
!= expected_result
)
431 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
432 result
, expected_result
);
437 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
438 10, 11, 12, 13, 14, 15, 16};
439 uchar_src2
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
440 0, 11, 12, 13, 14, 15, 16};
443 result
= vec_first_mismatch_index (uchar_src1
, uchar_src2
);
446 print_unsigned_char("src1", uchar_src1
);
447 print_unsigned_char("src2", uchar_src2
);
448 printf("vec_first_mismatch_index = %d\n\n", result
);
451 if (result
!= expected_result
)
453 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
454 result
, expected_result
);
459 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
460 10, 11, 12, 13, 14, 15, 16};
461 uchar_src2
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
462 10, 11, 12, 13, 14, 15, 16};
463 expected_result
= 16;
465 result
= vec_first_mismatch_index (uchar_src1
, uchar_src2
);
468 print_unsigned_char("src1", uchar_src1
);
469 print_unsigned_char("src2", uchar_src2
);
470 printf("vec_first_mismatch_index = %d\n\n", result
);
473 if (result
!= expected_result
)
475 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
476 result
, expected_result
);
482 short_src1
= (vector
short int) {-10, -20, 30, 40, 50, 60, 70, 80};
483 short_src2
= (vector
short int) {-10, 20, 30, 40, 50, 60, 70, 80};
487 result
= vec_first_mismatch_index (short_src1
, short_src2
);
490 print_signed_short_int("src1", short_src1
);
491 print_signed_short_int("src2", short_src2
);
492 printf("vec_first_mismatch_index = %d\n\n", result
);
495 if (result
!= expected_result
)
497 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
498 result
, expected_result
);
503 short_src1
= (vector
short int) {10, 20, 30, 40, 50, 60, 70, 80};
504 short_src2
= (vector
short int) {10, 20, 30, 40, 50, 60, 70, 80};
508 result
= vec_first_mismatch_index (short_src1
, short_src2
);
511 print_signed_short_int("src1", short_src1
);
512 print_signed_short_int("src2", short_src2
);
513 printf("vec_first_mismatch_index = %d\n\n", result
);
516 if (result
!= expected_result
)
518 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
519 result
, expected_result
);
524 ushort_src1
= (vector
short unsigned int) {10, 20, 30, 40, 50, 60, 70, 0};
525 ushort_src2
= (vector
short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
529 result
= vec_first_mismatch_index (ushort_src1
, ushort_src2
);
532 print_unsigned_short_int("src1", ushort_src1
);
533 print_unsigned_short_int("src2", ushort_src2
);
534 printf("vec_first_mismatch_index = %d\n\n", result
);
537 if (result
!= expected_result
)
539 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
540 result
, expected_result
);
545 ushort_src1
= (vector
short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
546 ushort_src2
= (vector
short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
550 result
= vec_first_mismatch_index (ushort_src1
, ushort_src2
);
553 print_unsigned_short_int("src1", ushort_src1
);
554 print_unsigned_short_int("src2", ushort_src2
);
555 printf("vec_first_mismatch_index = %d\n\n", result
);
558 if (result
!= expected_result
)
560 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
561 result
, expected_result
);
567 int_src1
= (vector
int) {1, 2, 3, 4};
568 int_src2
= (vector
int) {1, 20, 3, 4};
572 result
= vec_first_mismatch_index (int_src1
, int_src2
);
575 print_signed_int("src1", int_src1
);
576 print_signed_int("src2", int_src2
);
577 printf("vec_first_mismatch_index = %d\n\n", result
);
580 if (result
!= expected_result
)
582 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
583 result
, expected_result
);
588 int_src1
= (vector
int) {1, 2, 3, 4};
589 int_src2
= (vector
int) {1, 2, 3, 4};
593 result
= vec_first_mismatch_index (int_src1
, int_src2
);
596 print_signed_int("src1", int_src1
);
597 print_signed_int("src2", int_src2
);
598 printf("vec_first_mismatch_index = %d\n\n", result
);
601 if (result
!= expected_result
)
603 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
604 result
, expected_result
);
609 int_src1
= (vector
int) {1, 0, 3, 4};
610 int_src2
= (vector
int) {1, 2, 3, 4};
614 result
= vec_first_mismatch_index (int_src1
, int_src2
);
617 print_signed_int("src1", int_src1
);
618 print_signed_int("src2", int_src2
);
619 printf("vec_first_mismatch_index = %d\n\n", result
);
622 if (result
!= expected_result
)
624 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
625 result
, expected_result
);
630 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
631 uint_src2
= (vector
unsigned int) {11, 2, 33, 4};
635 result
= vec_first_mismatch_index (uint_src1
, uint_src2
);
638 print_unsigned_int("src1", uint_src1
);
639 print_unsigned_int("src2", uint_src2
);
640 printf("vec_first_mismatch_index = %d\n\n", result
);
643 if (result
!= expected_result
)
645 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
646 result
, expected_result
);
651 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
652 uint_src2
= (vector
unsigned int) {1, 2, 3, 4};
656 result
= vec_first_mismatch_index (uint_src1
, uint_src2
);
659 print_unsigned_int("src1", uint_src1
);
660 print_unsigned_int("src2", uint_src2
);
661 printf("vec_first_mismatch_index = %d\n\n", result
);
664 if (result
!= expected_result
)
667 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
668 result
, expected_result
);
673 /* Tests for: vec_first_match_or_eos_index()
674 The element index in BE order is returned for the first match
675 or the number of elements if there is no match. */
677 char_src1
= (vector
signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
678 9, 10, 11, 12, 13, 14, 15, 16};
679 char_src2
= (vector
signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
680 9, 10, 11, 12, 13, 14, 15, 16};
683 result
= vec_first_match_or_eos_index (char_src1
, char_src2
);
686 print_signed_char("src1", char_src1
);
687 print_signed_char("src2", char_src2
);
688 printf("vec_first_match_or_eos_index = %d\n\n", result
);
691 if (result
!= expected_result
)
693 printf("Error: char first match result (%d) does not match expected result (%d)\n",
694 result
, expected_result
);
699 char_src1
= (vector
signed char) {-1, 2, 3, 0, -5, 6, 7, 8,
700 9, 10, 11, 12, 13, 14, 15, 16};
701 char_src2
= (vector
signed char) {2, 3, 20, 0, -5, 6, 7, 8,
702 9, 10, 11, 12, 13, 14, 15, 16};
705 result
= vec_first_match_or_eos_index (char_src1
, char_src2
);
708 print_signed_char("src1", char_src1
);
709 print_signed_char("src2", char_src2
);
710 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
713 if (result
!= expected_result
)
715 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
716 result
, expected_result
);
721 char_src1
= (vector
signed char) {1, 2, 3, 4, 5, 6, 7, 8,
722 9, 10, 11, 12, 13, 14, 15, 16};
723 char_src2
= (vector
signed char) {-1, -2, -3, -4, -5, -6, -7, -8,
724 -9, -10, -11, -12, -13, -14, -15, -16};
725 expected_result
= 16;
727 result
= vec_first_match_or_eos_index (char_src1
, char_src2
);
730 print_signed_char("src1", char_src1
);
731 print_signed_char("src2", char_src2
);
732 printf("vec_first_match_or_eos_index = %d\n\n", result
);
735 if (result
!= expected_result
)
737 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
738 result
, expected_result
);
743 uchar_src1
= (vector
unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
744 9, 10, 11, 12, 13, 14, 15, 16};
745 uchar_src2
= (vector
unsigned char) {-1, 0, -3, -4, -5, -6, -7, -8,
746 9, 10, 11, 12, 13, 14, 15, 16};
749 result
= vec_first_match_or_eos_index (uchar_src1
, uchar_src2
);
752 print_unsigned_char("src1", uchar_src1
);
753 print_unsigned_char("src2", uchar_src2
);
754 printf("vec_first_match_or_eos_index = %d\n\n", result
);
757 if (result
!= expected_result
)
759 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
760 result
, expected_result
);
765 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
766 10, 11, 12, 13, 14, 15, 16, 17};
767 uchar_src2
= (vector
unsigned char) {3, 4, 5, 6, 7, 8, 9, 10,
768 11, 12, 13, 14, 15, 16, 17, 18};
769 expected_result
= 16;
771 result
= vec_first_match_or_eos_index (uchar_src1
, uchar_src2
);
774 print_unsigned_char("src1", uchar_src1
);
775 print_unsigned_char("src2", uchar_src2
);
776 printf("vec_first_match_or_eos_index = %d\n\n", result
);
779 if (result
!= expected_result
)
781 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
782 result
, expected_result
);
788 short_src1
= (vector
short int) {10, -20, -30, 40, 50, 60, 70, 80};
789 short_src2
= (vector
short int) {-10, 20, 30, 40, 50, 60, 70, 80};
793 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
796 print_signed_short_int("src1", short_src1
);
797 print_signed_short_int("src2", short_src2
);
798 printf("vec_first_match_or_eos_index = %d\n\n", result
);
801 if (result
!= expected_result
)
803 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
804 result
, expected_result
);
809 short_src1
= (vector
short int) {1, 20, 30, 40, 50, 60, 70, 80};
810 short_src2
= (vector
short int) {10, 0, 30, 40, 50, 60, 70, 80};
814 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
817 print_signed_short_int("src1", short_src1
);
818 print_signed_short_int("src2", short_src2
);
819 printf("vec_first_match_or_eos_index = %d\n\n", result
);
822 if (result
!= expected_result
)
824 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
825 result
, expected_result
);
830 short_src1
= (vector
short int) {-10, -20, -30, -40, -50, -60, -70, -80};
831 short_src2
= (vector
short int) {10, 20, 30, 40, 50, 0, 70, 80};
835 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
838 print_signed_short_int("src1", short_src1
);
839 print_signed_short_int("src2", short_src2
);
840 printf("vec_first_match_or_eos_index = %d\n\n", result
);
843 if (result
!= expected_result
)
845 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
846 result
, expected_result
);
851 short_src1
= (vector
short int) {10, 20, 30, 40, 50, 60, 70, 80};
852 short_src2
= (vector
short int) {0, 0, 0, 0, 0, 0, 0, 0};
856 result
= vec_first_match_or_eos_index (short_src1
, short_src2
);
859 print_signed_short_int("src1", short_src1
);
860 print_signed_short_int("src2", short_src2
);
861 printf("vec_first_match_or_eos_index = %d\n\n", result
);
864 if (result
!= expected_result
)
866 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
867 result
, expected_result
);
872 ushort_src1
= (vector
short unsigned int) {1, 2, 0, 0, 60, 70, 0};
873 ushort_src2
= (vector
short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
877 result
= vec_first_match_or_eos_index (ushort_src1
, ushort_src2
);
880 print_unsigned_short_int("src1", ushort_src1
);
881 print_unsigned_short_int("src2", ushort_src2
);
882 printf("vec_first_match_or_eos_index = %d\n\n", result
);
885 if (result
!= expected_result
)
887 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
888 result
, expected_result
);
893 ushort_src1
= (vector
short unsigned int) {-20, 30, -40, 50,
895 ushort_src2
= (vector
short unsigned int) {20, -30, 40, -50,
900 result
= vec_first_match_or_eos_index (ushort_src1
, ushort_src2
);
903 print_unsigned_short_int("src1", ushort_src1
);
904 print_unsigned_short_int("src2", ushort_src2
);
905 printf("vec_first_match_or_eos_index = %d\n\n", result
);
908 if (result
!= expected_result
)
910 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
911 result
, expected_result
);
915 ushort_src1
= (vector
short unsigned int) {-20, 30, -40, 50,
917 ushort_src2
= (vector
short unsigned int) {20, -30, 40, -50,
922 result
= vec_first_match_or_eos_index (ushort_src1
, ushort_src2
);
925 print_unsigned_short_int("src1", ushort_src1
);
926 print_unsigned_short_int("src2", ushort_src2
);
927 printf("vec_first_match_or_eos_index = %d\n\n", result
);
930 if (result
!= expected_result
)
932 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
933 result
, expected_result
);
939 int_src1
= (vector
int) {1, 2, 3, 4};
940 int_src2
= (vector
int) {10, 20, 30, 4};
944 result
= vec_first_match_or_eos_index (int_src1
, int_src2
);
947 print_signed_int("src1", int_src1
);
948 print_signed_int("src2", int_src2
);
949 printf("vec_first_match_or_eos_index = %d\n\n", result
);
952 if (result
!= expected_result
)
954 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
955 result
, expected_result
);
960 int_src1
= (vector
int) {0, 2, 3, 4};
961 int_src2
= (vector
int) {4, 3, 2, 1};
965 result
= vec_first_match_or_eos_index (int_src1
, int_src2
);
968 print_signed_int("src1", int_src1
);
969 print_signed_int("src2", int_src2
);
970 printf("vec_first_match_or_eos_index = %d\n\n", result
);
973 if (result
!= expected_result
)
975 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
976 result
, expected_result
);
981 int_src1
= (vector
int) {1, 2, 3, 4};
982 int_src2
= (vector
int) {4, 3, 2, 1};
986 result
= vec_first_match_or_eos_index (int_src1
, int_src2
);
989 print_signed_int("src1", int_src1
);
990 print_signed_int("src2", int_src2
);
991 printf("vec_first_match_or_eos_index = %d\n\n", result
);
994 if (result
!= expected_result
)
996 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
997 result
, expected_result
);
1002 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
1003 uint_src2
= (vector
unsigned int) {11, 2, 33, 4};
1005 expected_result
= 1;
1007 result
= vec_first_match_or_eos_index (uint_src1
, uint_src2
);
1010 print_unsigned_int("src1", uint_src1
);
1011 print_unsigned_int("src2", uint_src2
);
1012 printf("vec_first_match_or_eos_index = %d\n\n", result
);
1015 if (result
!= expected_result
)
1017 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1018 result
, expected_result
);
1023 uint_src1
= (vector
unsigned int) {1, 2, 0, 4};
1024 uint_src2
= (vector
unsigned int) {2, 3, 4, 5};
1026 expected_result
= 2;
1028 result
= vec_first_match_or_eos_index (uint_src1
, uint_src2
);
1031 print_unsigned_int("src1", uint_src1
);
1032 print_unsigned_int("src2", uint_src2
);
1033 printf("vec_first_match_or_eos_index = %d\n\n", result
);
1036 if (result
!= expected_result
)
1038 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1039 result
, expected_result
);
1044 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
1045 uint_src2
= (vector
unsigned int) {2, 3, 4, 5};
1047 expected_result
= 4;
1049 result
= vec_first_match_or_eos_index (uint_src1
, uint_src2
);
1052 print_unsigned_int("src1", uint_src1
);
1053 print_unsigned_int("src2", uint_src2
);
1054 printf("vec_first_match_or_eos_index = %d\n\n", result
);
1057 if (result
!= expected_result
)
1059 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1060 result
, expected_result
);
1065 /* Tests for: vec_first_mismatch_or_eos_index()
1066 The element index in BE order is returned for the first mismatch
1067 or the number of elements if there is no match. */
1069 char_src1
= (vector
signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
1070 9, 10, 11, 12, 13, 14, 15, 16};
1071 char_src2
= (vector
signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
1072 9, 10, 11, 12, 13, 14, 15, 16};
1073 expected_result
= 3;
1075 result
= vec_first_mismatch_or_eos_index (char_src1
, char_src2
);
1078 print_signed_char("src1", char_src1
);
1079 print_signed_char("src2", char_src2
);
1080 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1083 if (result
!= expected_result
)
1085 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1086 result
, expected_result
);
1091 char_src1
= (vector
signed char) {1, 2, 0, 4, 5, 6, 7, 8,
1092 9, 10, 11, 12, 13, 14, 15, 16};
1093 char_src2
= (vector
signed char) {1, 2, 0, 4, 5, 6, 7, 8,
1094 9, 10, 11, 12, 13, 14, 15, 16};
1095 expected_result
= 2;
1097 result
= vec_first_mismatch_or_eos_index (char_src1
, char_src2
);
1100 print_signed_char("src1", char_src1
);
1101 print_signed_char("src2", char_src2
);
1102 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1105 if (result
!= expected_result
)
1107 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1108 result
, expected_result
);
1113 char_src1
= (vector
signed char) {1, 2, 3, 4, 5, 6, 7, 8,
1114 9, 10, 11, 12, 13, 14, 15, 16};
1115 char_src2
= (vector
signed char) {1, 2, 3, 4, 5, 6, 7, 8,
1116 9, 10, 11, 12, 13, 14, 15, 16};
1117 expected_result
= 16;
1119 result
= vec_first_mismatch_or_eos_index (char_src1
, char_src2
);
1122 print_signed_char("src1", char_src1
);
1123 print_signed_char("src2", char_src2
);
1124 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1127 if (result
!= expected_result
)
1129 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1130 result
, expected_result
);
1135 uchar_src1
= (vector
unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
1136 9, 10, 11, 12, 13, 14, 15, 16};
1137 uchar_src2
= (vector
unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
1138 9, 10, 11, 12, 13, 14, 15, 16};
1139 expected_result
= 1;
1141 result
= vec_first_mismatch_or_eos_index (uchar_src1
, uchar_src2
);
1144 print_unsigned_char("src1", uchar_src1
);
1145 print_unsigned_char("src2", uchar_src2
);
1146 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1149 if (result
!= expected_result
)
1151 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1152 result
, expected_result
);
1157 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1158 0, 11, 12, 13, 14, 15, 16};
1159 uchar_src2
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1160 0, 11, 12, 13, 14, 15, 16};
1161 expected_result
= 8;
1163 result
= vec_first_mismatch_or_eos_index (uchar_src1
, uchar_src2
);
1166 print_unsigned_char("src1", uchar_src1
);
1167 print_unsigned_char("src2", uchar_src2
);
1168 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1171 if (result
!= expected_result
)
1173 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1174 result
, expected_result
);
1179 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1180 10, 11, 12, 13, 14, 15, 16, 17};
1181 uchar_src2
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1182 10, 11, 12, 13, 14, 0, 16, 17};
1183 expected_result
= 13;
1185 result
= vec_first_mismatch_or_eos_index (uchar_src1
, uchar_src2
);
1188 print_unsigned_char("src1", uchar_src1
);
1189 print_unsigned_char("src2", uchar_src2
);
1190 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1193 if (result
!= expected_result
)
1195 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1196 result
, expected_result
);
1201 uchar_src1
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1202 10, 11, 12, 13, 14, 15, 16, 17};
1203 uchar_src2
= (vector
unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
1204 10, 11, 12, 13, 14, 15, 16, 17};
1205 expected_result
= 16;
1207 result
= vec_first_mismatch_or_eos_index (uchar_src1
, uchar_src2
);
1210 print_unsigned_char("src1", uchar_src1
);
1211 print_unsigned_char("src2", uchar_src2
);
1212 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1215 if (result
!= expected_result
)
1217 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1218 result
, expected_result
);
1224 short_src1
= (vector
short int) {-10, -20, 30, 40, 50, 60, 70, 80};
1225 short_src2
= (vector
short int) {-10, 20, 30, 40, 50, 60, 70, 80};
1227 expected_result
= 1;
1229 result
= vec_first_mismatch_or_eos_index (short_src1
, short_src2
);
1232 print_signed_short_int("src1", short_src1
);
1233 print_signed_short_int("src2", short_src2
);
1234 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1237 if (result
!= expected_result
)
1239 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1240 result
, expected_result
);
1245 short_src1
= (vector
short int) {0, 20, 30, 40, 50, 60, 70, 80};
1246 short_src2
= (vector
short int) {0, 20, 30, 40, 50, 60, 70, 80};
1248 expected_result
= 0;
1250 result
= vec_first_mismatch_or_eos_index (short_src1
, short_src2
);
1253 print_signed_short_int("src1", short_src1
);
1254 print_signed_short_int("src2", short_src2
);
1255 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1258 if (result
!= expected_result
)
1260 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1261 result
, expected_result
);
1266 short_src1
= (vector
short int) {10, 20, 30, 40, 50, 60, 70, 80};
1267 short_src2
= (vector
short int) {10, 20, 30, 40, 50, 60, 70, 80};
1269 expected_result
= 8;
1271 result
= vec_first_mismatch_or_eos_index (short_src1
, short_src2
);
1274 print_signed_short_int("src1", short_src1
);
1275 print_signed_short_int("src2", short_src2
);
1276 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1279 if (result
!= expected_result
)
1281 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1282 result
, expected_result
);
1287 short_src1
= (vector
short int) {10, 0, 30, 40, 50, 60, 70, 80};
1288 short_src2
= (vector
short int) {10, 0, 30, 40, 50, 60, 70, 80};
1290 expected_result
= 1;
1292 result
= vec_first_mismatch_or_eos_index (short_src1
, short_src2
);
1295 print_signed_short_int("src1", short_src1
);
1296 print_signed_short_int("src2", short_src2
);
1297 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1300 if (result
!= expected_result
)
1302 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1303 result
, expected_result
);
1308 ushort_src1
= (vector
short unsigned int) {10, 20, 30, 40, 50, 60, 70, 0};
1309 ushort_src2
= (vector
short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
1311 expected_result
= 7;
1313 result
= vec_first_mismatch_or_eos_index (ushort_src1
, ushort_src2
);
1316 print_unsigned_short_int("src1", ushort_src1
);
1317 print_unsigned_short_int("src2", ushort_src2
);
1318 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1321 if (result
!= expected_result
)
1323 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1324 result
, expected_result
);
1329 ushort_src1
= (vector
short unsigned int) {20, 0, 40, 50, 60, 70, 80, 90};
1330 ushort_src2
= (vector
short unsigned int) {20, 0, 40, 50, 60, 70, 80, 90};
1332 expected_result
= 1;
1334 result
= vec_first_mismatch_or_eos_index (ushort_src1
, ushort_src2
);
1337 print_unsigned_short_int("src1", ushort_src1
);
1338 print_unsigned_short_int("src2", ushort_src2
);
1339 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1342 if (result
!= expected_result
)
1344 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1345 result
, expected_result
);
1350 ushort_src1
= (vector
short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
1351 ushort_src2
= (vector
short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
1353 expected_result
= 8;
1355 result
= vec_first_mismatch_or_eos_index (ushort_src1
, ushort_src2
);
1358 print_unsigned_short_int("src1", ushort_src1
);
1359 print_unsigned_short_int("src2", ushort_src2
);
1360 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1363 if (result
!= expected_result
)
1365 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1366 result
, expected_result
);
1372 int_src1
= (vector
int) {1, 2, 3, 4};
1373 int_src2
= (vector
int) {1, 20, 3, 4};
1375 expected_result
= 1;
1377 result
= vec_first_mismatch_or_eos_index (int_src1
, int_src2
);
1380 print_signed_int("src1", int_src1
);
1381 print_signed_int("src2", int_src2
);
1382 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1385 if (result
!= expected_result
)
1387 printf("Error: int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1388 result
, expected_result
);
1393 int_src1
= (vector
int) {1, 2, 3, 4};
1394 int_src2
= (vector
int) {1, 2, 3, 4};
1396 expected_result
= 4;
1398 result
= vec_first_mismatch_or_eos_index (int_src1
, int_src2
);
1401 print_signed_int("src1", int_src1
);
1402 print_signed_int("src2", int_src2
);
1403 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1406 if (result
!= expected_result
)
1408 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1409 result
, expected_result
);
1414 int_src1
= (vector
int) {1, 2, 0, 4};
1415 int_src2
= (vector
int) {1, 2, 0, 4};
1417 expected_result
= 2;
1419 result
= vec_first_mismatch_or_eos_index (int_src1
, int_src2
);
1422 print_signed_int("src1", int_src1
);
1423 print_signed_int("src2", int_src2
);
1424 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1427 if (result
!= expected_result
)
1429 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1430 result
, expected_result
);
1435 int_src1
= (vector
int) {1, 0, 3, 4};
1436 int_src2
= (vector
int) {1, 2, 3, 4};
1438 expected_result
= 1;
1440 result
= vec_first_mismatch_or_eos_index (int_src1
, int_src2
);
1443 print_signed_int("src1", int_src1
);
1444 print_signed_int("src2", int_src2
);
1445 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1447 if (result
!= expected_result
)
1449 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1450 result
, expected_result
);
1455 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
1456 uint_src2
= (vector
unsigned int) {11, 2, 33, 4};
1458 expected_result
= 0;
1460 result
= vec_first_mismatch_or_eos_index (uint_src1
, uint_src2
);
1463 print_unsigned_int("src1", uint_src1
);
1464 print_unsigned_int("src2", uint_src2
);
1465 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1467 if (result
!= expected_result
)
1469 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1470 result
, expected_result
);
1475 uint_src1
= (vector
unsigned int) {1, 2, 3, 0};
1476 uint_src2
= (vector
unsigned int) {1, 2, 3, 0};
1478 expected_result
= 3;
1480 result
= vec_first_mismatch_or_eos_index (uint_src1
, uint_src2
);
1483 print_unsigned_int("src1", uint_src1
);
1484 print_unsigned_int("src2", uint_src2
);
1485 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1488 if (result
!= expected_result
)
1490 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1491 result
, expected_result
);
1496 uint_src1
= (vector
unsigned int) {1, 2, 3, 4};
1497 uint_src2
= (vector
unsigned int) {1, 2, 3, 4};
1499 expected_result
= 4;
1501 result
= vec_first_mismatch_or_eos_index (uint_src1
, uint_src2
);
1504 print_unsigned_int("src1", uint_src1
);
1505 print_unsigned_int("src2", uint_src2
);
1506 printf("vec_first_mismatch_or_eos_index = %d\n\n", result
);
1509 if (result
!= expected_result
)
1511 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1512 result
, expected_result
);