Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / builtins-8-p9-runnable.c
blob158de5eeea454db9c6533d7e4b987ddc3a9bda6a
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" } */
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) {-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};
111 expected_result = 0;
113 result = vec_first_match_index (char_src1, char_src2);
115 #ifdef DEBUG2
116 print_signed_char("src1", char_src1);
117 print_signed_char("src2", char_src2);
118 printf(" vec_first_match_index = %d\n\n", result);
119 #endif
121 if (result != expected_result)
122 #ifdef DEBUG
123 printf("Error: char first match result (%d) does not match expected result (%d)\n",
124 result, expected_result);
125 #else
126 abort();
127 #endif
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);
137 #ifdef DEBUG2
138 print_signed_char("src1", char_src1);
139 print_signed_char("src2", char_src2);
140 printf("vec_first_match_index = %d\n\n", result);
141 #endif
143 if (result != expected_result)
144 #ifdef DEBUG
145 printf("Error: char first match result (%d) does not match expected result (%d)\n",
146 result, expected_result);
147 #else
148 abort();
149 #endif
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};
155 expected_result = 2;
157 result = vec_first_match_index (uchar_src1, uchar_src2);
159 #ifdef DEBUG2
160 print_unsigned_char("src1", uchar_src1);
161 print_unsigned_char("src2", uchar_src2);
162 printf("vec_first_match_index = %d\n\n", result);
163 #endif
165 if (result != expected_result)
166 #ifdef DEBUG
167 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
168 result, expected_result);
169 #else
170 abort();
171 #endif
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);
181 #ifdef DEBUG2
182 print_unsigned_char("src1", uchar_src1);
183 print_unsigned_char("src2", uchar_src2);
184 printf("vec_first_match_index = %d\n\n", result);
185 #endif
187 if (result != expected_result)
188 #ifdef DEBUG
189 printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
190 result, expected_result);
191 #else
192 abort();
193 #endif
195 /* short int */
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};
199 expected_result = 3;
201 result = vec_first_match_index (short_src1, short_src2);
203 #ifdef DEBUG2
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);
207 #endif
209 if (result != expected_result)
210 #ifdef DEBUG
211 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
212 result, expected_result);
213 #else
214 abort();
215 #endif
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};
220 expected_result = 8;
222 result = vec_first_match_index (short_src1, short_src2);
224 #ifdef DEBUG2
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);
228 #endif
230 if (result != expected_result)
231 #ifdef DEBUG
232 printf("Error: short int first match result (%d) does not match expected result (%d)\n",
233 result, expected_result);
234 #else
235 abort();
236 #endif
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};
241 expected_result = 5;
243 result = vec_first_match_index (ushort_src1, ushort_src2);
245 #ifdef DEBUG2
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);
249 #endif
251 if (result != expected_result)
252 #ifdef DEBUG
253 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
254 result, expected_result);
255 #else
256 abort();
257 #endif
259 ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
260 60, -70, 80, -90};
261 ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
262 -60, 70, -80, 90};
264 expected_result = 8;
266 result = vec_first_match_index (ushort_src1, ushort_src2);
268 #ifdef DEBUG2
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);
272 #endif
274 if (result != expected_result)
275 #ifdef DEBUG
276 printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
277 result, expected_result);
278 #else
279 abort();
280 #endif
282 /* int */
283 int_src1 = (vector int) {1, 2, 3, 4};
284 int_src2 = (vector int) {10, 20, 30, 4};
286 expected_result = 3;
288 result = vec_first_match_index (int_src1, int_src2);
290 #ifdef DEBUG2
291 print_signed_int("src1", int_src1);
292 print_signed_int("src2", int_src2);
293 printf("vec_first_match_index = %d\n\n", result);
294 #endif
296 if (result != expected_result)
297 #ifdef DEBUG
298 printf("Error: int first match result (%d) does not match expected result (%d)\n",
299 result, expected_result);
300 #else
301 abort();
302 #endif
304 int_src1 = (vector int) {1, 2, 3, 4};
305 int_src2 = (vector int) {4, 3, 2, 1};
307 expected_result = 4;
309 result = vec_first_match_index (int_src1, int_src2);
311 #ifdef DEBUG2
312 print_signed_int("src1", int_src1);
313 print_signed_int("src2", int_src2);
314 printf("vec_first_match_index = %d\n\n", result);
315 #endif
317 if (result != expected_result)
318 #ifdef DEBUG
319 printf("Error: int first match result (%d) does not match expected result (%d)\n",
320 result, expected_result);
321 #else
322 abort();
323 #endif
325 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
326 uint_src2 = (vector unsigned int) {11, 2, 33, 4};
328 expected_result = 1;
330 result = vec_first_match_index (uint_src1, uint_src2);
332 #ifdef DEBUG2
333 print_unsigned_int("src1", uint_src1);
334 print_unsigned_int("src2", uint_src2);
335 printf("vec_first_match_index = %d\n\n", result);
336 #endif
338 if (result != expected_result)
339 #ifdef DEBUG
340 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
341 result, expected_result);
342 #else
343 abort();
344 #endif
346 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
347 uint_src2 = (vector unsigned int) {2, 3, 4, 5};
349 expected_result = 4;
351 result = vec_first_match_index (uint_src1, uint_src2);
353 #ifdef DEBUG2
354 print_unsigned_int("src1", uint_src1);
355 print_unsigned_int("src2", uint_src2);
356 printf("vec_first_match_index = %d\n\n", result);
357 #endif
359 if (result != expected_result)
360 #ifdef DEBUG
361 printf("Error: uint first match result (%d) does not match expected result (%d)\n",
362 result, expected_result);
363 #else
364 abort();
365 #endif
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. */
370 /* char */
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};
375 expected_result = 3;
377 result = vec_first_mismatch_index (char_src1, char_src2);
379 #ifdef DEBUG2
380 print_signed_char("src1", char_src1);
381 print_signed_char("src2", char_src2);
382 printf("vec_first_mismatch_index = %d\n\n", result);
383 #endif
385 if (result != expected_result)
386 #ifdef DEBUG
387 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
388 result, expected_result);
389 #else
390 abort();
391 #endif
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);
401 #ifdef DEBUG2
402 print_signed_char("src1", char_src1);
403 print_signed_char("src2", char_src2);
404 printf("vec_first_mismatch_index = %d\n\n", result);
405 #endif
407 if (result != expected_result)
408 #ifdef DEBUG
409 printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
410 result, expected_result);
411 #else
412 abort();
413 #endif
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};
419 expected_result = 1;
421 result = vec_first_mismatch_index (uchar_src1, uchar_src2);
423 #ifdef DEBUG2
424 print_unsigned_char("src1", uchar_src1);
425 print_unsigned_char("src2", uchar_src2);
426 printf("vec_first_mismatch_index = %d\n\n", result);
427 #endif
429 if (result != expected_result)
430 #ifdef DEBUG
431 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
432 result, expected_result);
433 #else
434 abort();
435 #endif
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};
441 expected_result = 8;
443 result = vec_first_mismatch_index (uchar_src1, uchar_src2);
445 #ifdef DEBUG2
446 print_unsigned_char("src1", uchar_src1);
447 print_unsigned_char("src2", uchar_src2);
448 printf("vec_first_mismatch_index = %d\n\n", result);
449 #endif
451 if (result != expected_result)
452 #ifdef DEBUG
453 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
454 result, expected_result);
455 #else
456 abort();
457 #endif
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);
467 #ifdef DEBUG2
468 print_unsigned_char("src1", uchar_src1);
469 print_unsigned_char("src2", uchar_src2);
470 printf("vec_first_mismatch_index = %d\n\n", result);
471 #endif
473 if (result != expected_result)
474 #ifdef DEBUG
475 printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
476 result, expected_result);
477 #else
478 abort();
479 #endif
481 /* short int */
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};
485 expected_result = 1;
487 result = vec_first_mismatch_index (short_src1, short_src2);
489 #ifdef DEBUG2
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);
493 #endif
495 if (result != expected_result)
496 #ifdef DEBUG
497 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
498 result, expected_result);
499 #else
500 abort();
501 #endif
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};
506 expected_result = 8;
508 result = vec_first_mismatch_index (short_src1, short_src2);
510 #ifdef DEBUG2
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);
514 #endif
516 if (result != expected_result)
517 #ifdef DEBUG
518 printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
519 result, expected_result);
520 #else
521 abort();
522 #endif
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};
527 expected_result = 7;
529 result = vec_first_mismatch_index (ushort_src1, ushort_src2);
531 #ifdef DEBUG2
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);
535 #endif
537 if (result != expected_result)
538 #ifdef DEBUG
539 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
540 result, expected_result);
541 #else
542 abort();
543 #endif
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};
548 expected_result = 8;
550 result = vec_first_mismatch_index (ushort_src1, ushort_src2);
552 #ifdef DEBUG2
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);
556 #endif
558 if (result != expected_result)
559 #ifdef DEBUG
560 printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
561 result, expected_result);
562 #else
563 abort();
564 #endif
566 /* int */
567 int_src1 = (vector int) {1, 2, 3, 4};
568 int_src2 = (vector int) {1, 20, 3, 4};
570 expected_result = 1;
572 result = vec_first_mismatch_index (int_src1, int_src2);
574 #ifdef DEBUG2
575 print_signed_int("src1", int_src1);
576 print_signed_int("src2", int_src2);
577 printf("vec_first_mismatch_index = %d\n\n", result);
578 #endif
580 if (result != expected_result)
581 #ifdef DEBUG
582 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
583 result, expected_result);
584 #else
585 abort();
586 #endif
588 int_src1 = (vector int) {1, 2, 3, 4};
589 int_src2 = (vector int) {1, 2, 3, 4};
591 expected_result = 4;
593 result = vec_first_mismatch_index (int_src1, int_src2);
595 #ifdef DEBUG2
596 print_signed_int("src1", int_src1);
597 print_signed_int("src2", int_src2);
598 printf("vec_first_mismatch_index = %d\n\n", result);
599 #endif
601 if (result != expected_result)
602 #ifdef DEBUG
603 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
604 result, expected_result);
605 #else
606 abort();
607 #endif
609 int_src1 = (vector int) {1, 0, 3, 4};
610 int_src2 = (vector int) {1, 2, 3, 4};
612 expected_result = 1;
614 result = vec_first_mismatch_index (int_src1, int_src2);
616 #ifdef DEBUG2
617 print_signed_int("src1", int_src1);
618 print_signed_int("src2", int_src2);
619 printf("vec_first_mismatch_index = %d\n\n", result);
620 #endif
622 if (result != expected_result)
623 #ifdef DEBUG
624 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
625 result, expected_result);
626 #else
627 abort();
628 #endif
630 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
631 uint_src2 = (vector unsigned int) {11, 2, 33, 4};
633 expected_result = 0;
635 result = vec_first_mismatch_index (uint_src1, uint_src2);
637 #ifdef DEBUG2
638 print_unsigned_int("src1", uint_src1);
639 print_unsigned_int("src2", uint_src2);
640 printf("vec_first_mismatch_index = %d\n\n", result);
641 #endif
643 if (result != expected_result)
644 #ifdef DEBUG
645 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
646 result, expected_result);
647 #else
648 abort();
649 #endif
651 uint_src1 = (vector unsigned int) {1, 2, 3, 4};
652 uint_src2 = (vector unsigned int) {1, 2, 3, 4};
654 expected_result = 4;
656 result = vec_first_mismatch_index (uint_src1, uint_src2);
658 #ifdef DEBUG2
659 print_unsigned_int("src1", uint_src1);
660 print_unsigned_int("src2", uint_src2);
661 printf("vec_first_mismatch_index = %d\n\n", result);
662 #endif
664 if (result != expected_result)
666 #ifdef DEBUG
667 printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
668 result, expected_result);
669 #else
670 abort();
671 #endif
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. */
676 /* char */
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};
681 expected_result = 0;
683 result = vec_first_match_or_eos_index (char_src1, char_src2);
685 #ifdef DEBUG2
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);
689 #endif
691 if (result != expected_result)
692 #ifdef DEBUG
693 printf("Error: char first match result (%d) does not match expected result (%d)\n",
694 result, expected_result);
695 #else
696 abort();
697 #endif
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};
703 expected_result = 3;
705 result = vec_first_match_or_eos_index (char_src1, char_src2);
707 #ifdef DEBUG2
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);
711 #endif
713 if (result != expected_result)
714 #ifdef DEBUG
715 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
716 result, expected_result);
717 #else
718 abort();
719 #endif
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);
729 #ifdef DEBUG2
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);
733 #endif
735 if (result != expected_result)
736 #ifdef DEBUG
737 printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
738 result, expected_result);
739 #else
740 abort();
741 #endif
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};
747 expected_result = 1;
749 result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
751 #ifdef DEBUG2
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);
755 #endif
757 if (result != expected_result)
758 #ifdef DEBUG
759 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
760 result, expected_result);
761 #else
762 abort();
763 #endif
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);
773 #ifdef DEBUG2
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);
777 #endif
779 if (result != expected_result)
780 #ifdef DEBUG
781 printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
782 result, expected_result);
783 #else
784 abort();
785 #endif
787 /* short int */
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};
791 expected_result = 3;
793 result = vec_first_match_or_eos_index (short_src1, short_src2);
795 #ifdef DEBUG2
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);
799 #endif
801 if (result != expected_result)
802 #ifdef DEBUG
803 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
804 result, expected_result);
805 #else
806 abort();
807 #endif
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};
812 expected_result = 1;
814 result = vec_first_match_or_eos_index (short_src1, short_src2);
816 #ifdef DEBUG2
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);
820 #endif
822 if (result != expected_result)
823 #ifdef DEBUG
824 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
825 result, expected_result);
826 #else
827 abort();
828 #endif
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};
833 expected_result = 5;
835 result = vec_first_match_or_eos_index (short_src1, short_src2);
837 #ifdef DEBUG2
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);
841 #endif
843 if (result != expected_result)
844 #ifdef DEBUG
845 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
846 result, expected_result);
847 #else
848 abort();
849 #endif
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};
854 expected_result = 0;
856 result = vec_first_match_or_eos_index (short_src1, short_src2);
858 #ifdef DEBUG2
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);
862 #endif
864 if (result != expected_result)
865 #ifdef DEBUG
866 printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
867 result, expected_result);
868 #else
869 abort();
870 #endif
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};
875 expected_result = 2;
877 result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
879 #ifdef DEBUG2
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);
883 #endif
885 if (result != expected_result)
886 #ifdef DEBUG
887 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
888 result, expected_result);
889 #else
890 abort();
891 #endif
893 ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
894 60, -70, 80, -90};
895 ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
896 -60, 70, -80, 90};
898 expected_result = 8;
900 result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
902 #ifdef DEBUG2
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);
906 #endif
908 if (result != expected_result)
909 #ifdef DEBUG
910 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
911 result, expected_result);
912 #else
913 abort();
914 #endif
915 ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
916 60, -70, 80, 0};
917 ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
918 -60, 70, -80, 90};
920 expected_result = 7;
922 result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
924 #ifdef DEBUG2
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);
928 #endif
930 if (result != expected_result)
931 #ifdef DEBUG
932 printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
933 result, expected_result);
934 #else
935 abort();
936 #endif
938 /* int */
939 int_src1 = (vector int) {1, 2, 3, 4};
940 int_src2 = (vector int) {10, 20, 30, 4};
942 expected_result = 3;
944 result = vec_first_match_or_eos_index (int_src1, int_src2);
946 #ifdef DEBUG2
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);
950 #endif
952 if (result != expected_result)
953 #ifdef DEBUG
954 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
955 result, expected_result);
956 #else
957 abort();
958 #endif
960 int_src1 = (vector int) {0, 2, 3, 4};
961 int_src2 = (vector int) {4, 3, 2, 1};
963 expected_result = 0;
965 result = vec_first_match_or_eos_index (int_src1, int_src2);
967 #ifdef DEBUG2
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);
971 #endif
973 if (result != expected_result)
974 #ifdef DEBUG
975 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
976 result, expected_result);
977 #else
978 abort();
979 #endif
981 int_src1 = (vector int) {1, 2, 3, 4};
982 int_src2 = (vector int) {4, 3, 2, 1};
984 expected_result = 4;
986 result = vec_first_match_or_eos_index (int_src1, int_src2);
988 #ifdef DEBUG2
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);
992 #endif
994 if (result != expected_result)
995 #ifdef DEBUG
996 printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
997 result, expected_result);
998 #else
999 abort();
1000 #endif
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);
1009 #ifdef DEBUG2
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);
1013 #endif
1015 if (result != expected_result)
1016 #ifdef DEBUG
1017 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1018 result, expected_result);
1019 #else
1020 abort();
1021 #endif
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);
1030 #ifdef DEBUG2
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);
1034 #endif
1036 if (result != expected_result)
1037 #ifdef DEBUG
1038 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1039 result, expected_result);
1040 #else
1041 abort();
1042 #endif
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);
1051 #ifdef DEBUG2
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);
1055 #endif
1057 if (result != expected_result)
1058 #ifdef DEBUG
1059 printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
1060 result, expected_result);
1061 #else
1062 abort();
1063 #endif
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. */
1068 /* char */
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);
1077 #ifdef DEBUG2
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);
1081 #endif
1083 if (result != expected_result)
1084 #ifdef DEBUG
1085 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1086 result, expected_result);
1087 #else
1088 abort();
1089 #endif
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);
1099 #ifdef DEBUG2
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);
1103 #endif
1105 if (result != expected_result)
1106 #ifdef DEBUG
1107 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1108 result, expected_result);
1109 #else
1110 abort();
1111 #endif
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);
1121 #ifdef DEBUG2
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);
1125 #endif
1127 if (result != expected_result)
1128 #ifdef DEBUG
1129 printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
1130 result, expected_result);
1131 #else
1132 abort();
1133 #endif
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);
1143 #ifdef DEBUG2
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);
1147 #endif
1149 if (result != expected_result)
1150 #ifdef DEBUG
1151 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1152 result, expected_result);
1153 #else
1154 abort();
1155 #endif
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);
1165 #ifdef DEBUG2
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);
1169 #endif
1171 if (result != expected_result)
1172 #ifdef DEBUG
1173 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1174 result, expected_result);
1175 #else
1176 abort();
1177 #endif
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);
1187 #ifdef DEBUG2
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);
1191 #endif
1193 if (result != expected_result)
1194 #ifdef DEBUG
1195 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1196 result, expected_result);
1197 #else
1198 abort();
1199 #endif
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);
1209 #ifdef DEBUG2
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);
1213 #endif
1215 if (result != expected_result)
1216 #ifdef DEBUG
1217 printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
1218 result, expected_result);
1219 #else
1220 abort();
1221 #endif
1223 /* short int */
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);
1231 #ifdef DEBUG2
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);
1235 #endif
1237 if (result != expected_result)
1238 #ifdef DEBUG
1239 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1240 result, expected_result);
1241 #else
1242 abort();
1243 #endif
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);
1252 #ifdef DEBUG2
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);
1256 #endif
1258 if (result != expected_result)
1259 #ifdef DEBUG
1260 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1261 result, expected_result);
1262 #else
1263 abort();
1264 #endif
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);
1273 #ifdef DEBUG2
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);
1277 #endif
1279 if (result != expected_result)
1280 #ifdef DEBUG
1281 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1282 result, expected_result);
1283 #else
1284 abort();
1285 #endif
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);
1294 #ifdef DEBUG2
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);
1298 #endif
1300 if (result != expected_result)
1301 #ifdef DEBUG
1302 printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1303 result, expected_result);
1304 #else
1305 abort();
1306 #endif
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);
1315 #ifdef DEBUG2
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);
1319 #endif
1321 if (result != expected_result)
1322 #ifdef DEBUG
1323 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1324 result, expected_result);
1325 #else
1326 abort();
1327 #endif
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);
1336 #ifdef DEBUG2
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);
1340 #endif
1342 if (result != expected_result)
1343 #ifdef DEBUG
1344 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1345 result, expected_result);
1346 #else
1347 abort();
1348 #endif
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);
1357 #ifdef DEBUG2
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);
1361 #endif
1363 if (result != expected_result)
1364 #ifdef DEBUG
1365 printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1366 result, expected_result);
1367 #else
1368 abort();
1369 #endif
1371 /* int */
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);
1379 #ifdef DEBUG2
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);
1383 #endif
1385 if (result != expected_result)
1386 #ifdef DEBUG
1387 printf("Error: int first mismatch or EOS result (%d) does not match expected result (%d)\n",
1388 result, expected_result);
1389 #else
1390 abort();
1391 #endif
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);
1400 #ifdef DEBUG2
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);
1404 #endif
1406 if (result != expected_result)
1407 #ifdef DEBUG
1408 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1409 result, expected_result);
1410 #else
1411 abort();
1412 #endif
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);
1421 #ifdef DEBUG2
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);
1425 #endif
1427 if (result != expected_result)
1428 #ifdef DEBUG
1429 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1430 result, expected_result);
1431 #else
1432 abort();
1433 #endif
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);
1442 #ifdef DEBUG2
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);
1446 #endif
1447 if (result != expected_result)
1448 #ifdef DEBUG
1449 printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
1450 result, expected_result);
1451 #else
1452 abort();
1453 #endif
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);
1462 #ifdef DEBUG2
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);
1466 #endif
1467 if (result != expected_result)
1468 #ifdef DEBUG
1469 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1470 result, expected_result);
1471 #else
1472 abort();
1473 #endif
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);
1482 #ifdef DEBUG2
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);
1486 #endif
1488 if (result != expected_result)
1489 #ifdef DEBUG
1490 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1491 result, expected_result);
1492 #else
1493 abort();
1494 #endif
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);
1503 #ifdef DEBUG2
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);
1507 #endif
1509 if (result != expected_result)
1510 #ifdef DEBUG
1511 printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
1512 result, expected_result);
1513 #else
1514 abort();
1515 #endif