#include <inttypes.h>
#include <altivec.h> // vector
+#define TRUE 1
+#define FALSE 0
+
#ifdef DEBUG
#include <stdio.h>
#endif
void abort (void);
-int main() {
- vector signed char char_src1, char_src2;
- vector unsigned char uchar_src1, uchar_src2;
- vector signed short int short_src1, short_src2;
- vector unsigned short int ushort_src1, ushort_src2;
- vector signed int int_src1, int_src2;
- vector unsigned int uint_src1, uint_src2;
- unsigned int result, expected_result;
-
- /* Tests for: vec_first_match_index() */
- /* char */
- char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 0;
-
- result = vec_first_match_index (char_src1, char_src2);
-
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: char first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+int result_wrong_sc (vector signed char vec_expected,
+ vector signed char vec_actual)
+{
+ int i;
- char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {-1, -2, -3, -4, -5, -6, -7, -8,
- -9, -10, -11, -12, -13, -14, -15, -16};
- expected_result = 16;
+ for (i = 0; i < 16; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- result = vec_first_match_index (char_src1, char_src2);
+ return FALSE;
+}
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: char first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+int result_wrong_uc (vector unsigned char vec_expected,
+ vector unsigned char vec_actual)
+{
+ int i;
- uchar_src1 = (vector unsigned char) {0, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 2;
+ for (i = 0; i < 16; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- result = vec_first_match_index (uchar_src1, uchar_src2);
+ return FALSE;
+}
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+int result_wrong_us (vector unsigned short vec_expected,
+ vector unsigned short vec_actual)
+{
+ int i;
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17};
- uchar_src2 = (vector unsigned char) {3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18};
- expected_result = 16;
+ for (i = 0; i < 8; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- result = vec_first_match_index (uchar_src1, uchar_src2);
+ return FALSE;
+}
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+int result_wrong_ss (vector signed short vec_expected,
+ vector signed short vec_actual)
+{
+ int i;
- /* short int */
- short_src1 = (vector short int) {10, -20, -30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
+ for (i = 0; i < 8; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- expected_result = 3;
+ return FALSE;
+}
- result = vec_first_match_index (short_src1, short_src2);
+int result_wrong_ui (vector unsigned int vec_expected,
+ vector unsigned int vec_actual)
+{
+ int i;
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: short int first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
+ for (i = 0; i < 4; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {0, 0, 0, 0, 0, 0, 0, 0};
+ return FALSE;
+}
- expected_result = 8;
+int result_wrong_ull (vector unsigned long long vec_expected,
+ vector unsigned long long vec_actual)
+{
+ int i;
- result = vec_first_match_index (short_src1, short_src2);
+ for (i = 0; i < 2; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: short int first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ return FALSE;
+}
- ushort_src1 = (vector short unsigned int) {0, 0, 0, 0, 0, 60, 70, 0};
- ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
+int result_wrong_sll (vector signed long long vec_expected,
+ vector signed long long vec_actual)
+{
+ int i;
- expected_result = 5;
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
+ }
- result = vec_first_match_index (ushort_src1, ushort_src2);
+ return FALSE;
+}
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+int result_wrong_si (vector signed int vec_expected,
+ vector signed int vec_actual)
+{
+ int i;
- ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
- 60, -70, 80, -90};
- ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
- -60, 70, -80, 90};
+ for (i = 0; i < 4; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- expected_result = 8;
+ return FALSE;
+}
- result = vec_first_match_index (ushort_src1, ushort_src2);
+int result_wrong_u128 (vector __uint128_t vec_expected,
+ vector __uint128_t vec_actual)
+{
+ int i;
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ if (vec_expected[0] != vec_actual[0])
+ return TRUE;
- /* int */
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {10, 20, 30, 4};
+ return FALSE;
+}
- expected_result = 3;
+int result_wrong_s128 (vector __int128_t vec_expected,
+ vector __int128_t vec_actual)
+{
+ int i;
- result = vec_first_match_index (int_src1, int_src2);
+ if (vec_expected[0] != vec_actual[0])
+ return TRUE;
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: int first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ return FALSE;
+}
+
+int result_wrong_d (vector double vec_expected,
+ vector double vec_actual)
+{
+ int i;
+
+ for (i = 0; i < 2; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
+
+ return FALSE;
+}
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {4, 3, 2, 1};
+int result_wrong_f (vector float vec_expected,
+ vector float vec_actual)
+{
+ int i;
- expected_result = 4;
+ for (i = 0; i < 4; i++)
+ if (vec_expected[i] != vec_actual[i])
+ return TRUE;
- result = vec_first_match_index (int_src1, int_src2);
+ return FALSE;
+}
- if (result != expected_result)
#ifdef DEBUG
- printf("Error: int first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+void print_sc (vector signed char vec_expected,
+ vector signed char vec_actual)
+{
+ int i;
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {11, 2, 33, 4};
+ printf("expected signed char data\n");
+ for (i = 0; i < 16; i++)
+ printf(" %d,", vec_expected[i]);
- expected_result = 1;
+ printf("\nactual signed char data\n");
+ for (i = 0; i < 16; i++)
+ printf(" %d,", vec_actual[i]);
+ printf("\n");
+}
- result = vec_first_match_index (uint_src1, uint_src2);
+void print_uc (vector unsigned char vec_expected,
+ vector unsigned char vec_actual)
+{
+ int i;
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uint first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("expected signed char data\n");
+ for (i = 0; i < 16; i++)
+ printf(" %d,", vec_expected[i]);
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {2, 3, 4, 5};
+ printf("\nactual signed char data\n");
+ for (i = 0; i < 16; i++)
+ printf(" %d,", vec_actual[i]);
+ printf("\n");
+}
- expected_result = 4;
+void print_us (vector unsigned short vec_expected,
+ vector unsigned short vec_actual)
+{
+ int i;
- result = vec_first_match_index (uint_src1, uint_src2);
+ printf("expected unsigned short data\n");
+ for (i = 0; i < 8; i++)
+ printf(" %d,", vec_expected[i]);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uint first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("\nactual unsigned short data\n");
+ for (i = 0; i < 8; i++)
+ printf(" %d,", vec_actual[i]);
+ printf("\n");
+}
- /* Tests for: vec_first_mismatch_index() */
- /* char */
- char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 3;
+void print_ss (vector signed short vec_expected,
+ vector signed short vec_actual)
+{
+ int i;
- result = vec_first_mismatch_index (char_src1, char_src2);
+ printf("expected signed short data\n");
+ for (i = 0; i < 8; i++)
+ printf(" %d,", vec_expected[i]);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("\nactual signed short data\n");
+ for (i = 0; i < 8; i++)
+ printf(" %d,", vec_actual[i]);
+ printf("\n");
+}
- char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 16;
+void print_ui (vector unsigned int vec_expected,
+ vector unsigned int vec_actual)
+{
+ int i;
- result = vec_first_mismatch_index (char_src1, char_src2);
+ printf("expected unsigned int data\n");
+ for (i = 0; i < 4; i++)
+ printf(" %d,", vec_expected[i]);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("\nactual unsigned int data\n");
+ for (i = 0; i < 4; i++)
+ printf(" %d,", vec_actual[i]);
+ printf("\n");
+}
- uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 1;
+void print_si (vector signed int vec_expected,
+ vector signed int vec_actual)
+{
+ int i;
- result = vec_first_mismatch_index (uchar_src1, uchar_src2);
+ printf("expected signed int data\n");
+ for (i = 0; i < 4; i++)
+ printf(" %d,", vec_expected[i]);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("\nactual signed int data\n");
+ for (i = 0; i < 4; i++)
+ printf(" %d,", vec_actual[i]);
+ printf("\n");
+}
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 0, 11, 12, 13, 14, 15, 16};
- expected_result = 8;
+void print_ull (vector unsigned long long vec_expected,
+ vector unsigned long long vec_actual)
+{
+ int i;
- result = vec_first_mismatch_index (uchar_src1, uchar_src2);
+ printf("expected unsigned long long data\n");
+ for (i = 0; i < 2; i++)
+ printf(" %llu,", vec_expected[i]);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("\nactual unsigned long long data\n");
+ for (i = 0; i < 2; i++)
+ printf(" %llu,", vec_actual[i]);
+ printf("\n");
+}
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16};
- expected_result = 16;
+void print_sll (vector signed long long vec_expected,
+ vector signed long long vec_actual)
+{
+ int i;
- result = vec_first_mismatch_index (uchar_src1, uchar_src2);
+ printf("expected signed long long data\n");
+ for (i = 0; i < 2; i++)
+ printf(" %lld,", vec_expected[i]);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
+ printf("\nactual signed long long data\n");
+ for (i = 0; i < 2; i++)
+ printf(" %lld,", vec_actual[i]);
+ printf("\n");
+}
- /* short int */
- short_src1 = (vector short int) {-10, -20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
+void print_u128 (vector __uint128_t vec_expected,
+ vector __uint128_t vec_actual)
+{
+ printf("expected uint128 data\n");
+ printf(" %llu%llu\n", (unsigned long long)(vec_expected[0] >> 64),
+ (unsigned long long)(vec_expected[0] & 0xFFFFFFFFFFFFFFFF));
- expected_result = 1;
+ printf("\nactual uint128 data\n");
+ printf(" %llu%llu\n", (unsigned long long)(vec_actual[0] >> 64),
+ (unsigned long long)(vec_actual[0] & 0xFFFFFFFFFFFFFFFF));
+}
- result = vec_first_mismatch_index (short_src1, short_src2);
+void print_s128 (vector __int128 vec_expected,
+ vector __int128 vec_actual)
+{
+ printf("expected int128 data\n");
+ printf(" %lld%llu\n", (signed long long)(vec_expected[0] >> 64),
+ (unsigned long long)(vec_expected[0] & 0xFFFFFFFFFFFFFFFF));
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
+ printf("\nactual int128 data\n");
+ printf(" %lld%llu\n", (signed long long)(vec_actual[0] >> 64),
+ (unsigned long long)(vec_actual[0] & 0xFFFFFFFFFFFFFFFF));
+}
+
+void print_d (vector double vec_expected,
+ vector double vec_actual)
+{
+ int i;
+
+ printf("expected double data\n");
+ for (i = 0; i < 2; i++)
+ printf(" %f,", vec_expected[i]);
+
+ printf("\nactual double data\n");
+ for (i = 0; i < 2; i++)
+ printf(" %f,", vec_actual[i]);
+ printf("\n");
+}
+
+void print_f (vector float vec_expected,
+ vector float vec_actual)
+{
+ int i;
+
+ printf("expected float data\n");
+ for (i = 0; i < 4; i++)
+ printf(" %f,", vec_expected[i]);
+
+ printf("\nactual float data\n");
+ for (i = 0; i < 4; i++)
+ printf(" %f,", vec_actual[i]);
+ printf("\n");
+}
#endif
- short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
+int main() {
+ int i, j;
+ size_t len;
+ signed char data_c[100];
+ vector signed char input_c;
+ unsigned char data_uc[100];
+ vector unsigned char input_uc;
+
+ signed short int data_ssi[100];
+ vector signed short int input_ssi;
+ unsigned short int data_usi[100];
+ vector unsigned short int input_usi;
+
+ signed int data_si[100];
+ vector signed int input_si;
+ unsigned int data_ui[100];
+ vector unsigned int input_ui;
+
+ signed long long data_sll[100];
+ vector signed long long input_sll;
+ unsigned long long data_ull[100];
+ vector unsigned long long int input_ull;
+
+ float data_f[100];
+ vector float input_f;
+ double data_d[100];
+ vector double input_d;
+ __uint128_t data_u128[100];
+ vector __uint128_t input_u128;
+ __int128_t data_128[100];
+ vector __int128_t input_128;
+
+ vector signed char store_data_sc;
+ vector unsigned char store_data_uc;
+ vector signed int store_data_si;
+ vector unsigned int store_data_ui;
+ vector __int128_t store_data_s128;
+ vector __uint128_t store_data_u128;
+ vector signed long long int store_data_sll;
+ vector unsigned long long int store_data_ull;
+ vector signed short store_data_ss;
+ vector unsigned short store_data_us;
+ vector double store_data_d;
+ vector float store_data_f;
+
+ signed char *address_sc;
+ unsigned char *address_uc;
+ signed int *address_si;
+ unsigned int *address_ui;
+ __int128_t *address_s128;
+ __uint128_t *address_u128;
+ signed long long int *address_sll;
+ unsigned long long int *address_ull;
+ signed short int *address_ss;
+ unsigned short int *address_us;
+ double *address_d;
+ float *address_f;
+
+ vector unsigned char *datap;
+
+ vector unsigned char vec_uc_expected1, vec_uc_result1;
+ vector signed char vec_sc_expected1, vec_sc_result1;
+ vector signed int vec_si_expected1, vec_si_result1;
+ vector unsigned int vec_ui_expected1, vec_ui_result1;
+ vector __int128_t vec_s128_expected1, vec_s128_result1;
+ vector __uint128_t vec_u128_expected1, vec_u128_result1;
+ vector signed long long int vec_sll_expected1, vec_sll_result1;
+ vector unsigned long long int vec_ull_expected1, vec_ull_result1;
+ vector signed short int vec_ss_expected1, vec_ss_result1;
+ vector unsigned short int vec_us_expected1, vec_us_result1;
+ vector double vec_d_expected1, vec_d_result1;
+ vector float vec_f_expected1, vec_f_result1;
+
+ signed long long disp;
+
+ /* VEC_XST_LEN, ISA 3.0 */
+ len = 16;
+ vec_sc_expected1 = (vector signed char){ -7, -6, -5, -4, -3, -2, -1, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8 };
+ store_data_sc = (vector signed char){ -7, -6, -5, -4, -3, -2, -1, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8 };
+ vec_sc_result1 = (vector signed char){ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
- expected_result = 8;
+ address_sc = &vec_sc_result1[0];
- result = vec_first_mismatch_index (short_src1, short_src2);
+ vec_xst_len (store_data_sc, address_sc, len);
- if (result != expected_result)
+ if (result_wrong_sc (vec_sc_expected1, vec_sc_result1))
+ {
#ifdef DEBUG
- printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, sc result does not match expected result\n", len);
+ print_sc (vec_sc_expected1, vec_sc_result1);
#else
- abort();
+ abort();
#endif
+ }
- ushort_src1 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 0};
- ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
+ len = 12;
+ vec_sc_expected1 = (vector signed char){ -7, -6, -5, -4, -3, -2, -1, 0,
+ 1, 2, 3, 4, 0, 0, 0, 0 };
+ store_data_sc = (vector signed char){ -7, -6, -5, -4, -3, -2, -1, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8 };
+ vec_sc_result1 = (vector signed char){ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
- expected_result = 7;
+ address_sc = &vec_sc_result1[0];
- result = vec_first_mismatch_index (ushort_src1, ushort_src2);
+ vec_xst_len (store_data_sc, address_sc, len);
- if (result != expected_result)
+ if (result_wrong_sc (vec_sc_expected1, vec_sc_result1))
+ {
#ifdef DEBUG
- printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, sc result does not match expected result\n",
+ len);
+ print_sc (vec_sc_expected1, vec_sc_result1);
#else
- abort();
+ abort();
#endif
+ }
+
+ len = 16;
+ vec_uc_expected1 = (vector unsigned char){ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15 };
+
+ store_data_uc = (vector unsigned char){ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15 };
- ushort_src1 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
- ushort_src2 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
+ vec_uc_result1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
- expected_result = 8;
+ address_uc = &vec_uc_result1[0];
- result = vec_first_mismatch_index (ushort_src1, ushort_src2);
+ vec_xst_len (store_data_uc, address_uc, len);
- if (result != expected_result)
+ if (result_wrong_uc (vec_uc_expected1, vec_uc_result1))
+ {
#ifdef DEBUG
- printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, uc result does not match expected result\n",
+ len);
+ print_uc (vec_uc_expected1, vec_uc_result1);
#else
abort();
#endif
+ }
- /* int */
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {1, 20, 3, 4};
+ len = 4;
+ vec_uc_expected1 = (vector unsigned char){ 0, 1, 2, 3, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
+ store_data_uc = (vector unsigned char){ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15 };
+ vec_uc_result1 = (vector unsigned char){ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
- expected_result = 1;
+ address_uc = &vec_uc_result1[0];
- result = vec_first_mismatch_index (int_src1, int_src2);
+ vec_xst_len (store_data_uc, address_uc, len);
- if (result != expected_result)
+ if (result_wrong_uc (vec_uc_expected1, vec_uc_result1))
+ {
#ifdef DEBUG
- printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, uc result does not match expected result\n",
+ len);
+ print_uc (vec_uc_expected1, vec_uc_result1);
#else
abort();
#endif
+ }
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {1, 2, 3, 4};
+ len = 16;
+ vec_ss_expected1 = (vector signed short int){ 10, 20, 30, 40,
+ 50, 60, 70, 80 };
+ store_data_ss = (vector signed short int){ 10, 20, 30, 40,
+ 50, 60, 70, 80 };
+ vec_ss_result1 = (vector signed short int){ 0, 0, 0, 0, 0, 0, 0, 0};
- expected_result = 4;
+ address_ss = &vec_ss_result1[0];
- result = vec_first_mismatch_index (int_src1, int_src2);
+ vec_xst_len (store_data_ss, address_ss, len);
- if (result != expected_result)
+ if (result_wrong_ss (vec_ss_expected1, vec_ss_result1))
+ {
#ifdef DEBUG
- printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, ss result does not match expected result\n",
+ len);
+ print_ss (vec_ss_expected1, vec_ss_result1);
#else
- abort();
+ abort();
#endif
+ }
- int_src1 = (vector int) {1, 0, 3, 4};
- int_src2 = (vector int) {1, 2, 3, 4};
+ len = 14;
+ vec_ss_expected1 = (vector signed short int){ 10, 20, 30, 40,
+ 50, 60, 70, 0 };
+ store_data_ss = (vector signed short int){ 10, 20, 30, 40,
+ 50, 60, 70, 80 };
+ vec_ss_result1 = (vector signed short int){ 0, 0, 0, 0, 0, 0, 0, 0};
- expected_result = 1;
+ address_ss = &vec_ss_result1[0];
- result = vec_first_mismatch_index (int_src1, int_src2);
+ vec_xst_len (store_data_ss, address_ss, len);
- if (result != expected_result)
+ if (result_wrong_ss (vec_ss_expected1, vec_ss_result1))
+ {
#ifdef DEBUG
- printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, ss result does not match expected result\n",
+ len);
+ print_ss (vec_ss_expected1, vec_ss_result1);
#else
- abort();
+ abort();
#endif
+ }
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {11, 2, 33, 4};
+ len = 16;
+ vec_us_expected1 = (vector unsigned short int){ 10, 20, 30, 40,
+ 50, 60, 70, 80 };
+ store_data_us = (vector unsigned short int){ 10, 20, 30, 40,
+ 50, 60, 70, 80 };
+ vec_us_result1 = (vector unsigned short int){ 0, 0, 0, 0, 0, 0, 0, 0};
- expected_result = 0;
+ address_us = &vec_us_result1[0];
- result = vec_first_mismatch_index (uint_src1, uint_src2);
+ vec_xst_len (store_data_us, address_us, len);
- if (result != expected_result)
+ if (result_wrong_us (vec_us_expected1, vec_us_result1))
+ {
#ifdef DEBUG
- printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, us result does not match expected result\n",
+ len);
+ print_us (vec_us_expected1, vec_us_result1);
#else
- abort();
+ abort();
#endif
+ }
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {1, 2, 3, 4};
+ len = 2;
+ vec_us_expected1 = (vector unsigned short int){ 10, 0, 0, 0,
+ 0, 0, 0, 0 };
+ store_data_us = (vector unsigned short int){ 10, 20, 30, 40,
+ 50, 60, 70, 80 };
+ vec_us_result1 = (vector unsigned short int){ 0, 0, 0, 0, 0, 0, 0, 0};
- expected_result = 4;
+ address_us = &vec_us_result1[0];
- result = vec_first_mismatch_index (uint_src1, uint_src2);
+ vec_xst_len (store_data_us, address_us, len);
- if (result != expected_result)
+ if (result_wrong_us (vec_us_expected1, vec_us_result1))
+ {
#ifdef DEBUG
- printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, us result does not match expected result\n",
+ len);
+ print_us (vec_us_expected1, vec_us_result1);
#else
- abort();
+ abort();
#endif
+ }
- /* Tests for: vec_first_match_or_eos_index() */
- /* char */
- char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 0;
+ len = 16;
+ vec_si_expected1 = (vector signed int){ -30, -10, 0, 10 };
+ store_data_si = (vector signed int){ -30, -10, 0, 10 };
+ vec_si_result1 = (vector signed int){ 0, 0, 0, 0};
- result = vec_first_match_or_eos_index (char_src1, char_src2);
+ address_si = &vec_si_result1[0];
- if (result != expected_result)
+ vec_xst_len (store_data_si, address_si, len);
+
+ if (result_wrong_si (vec_si_expected1, vec_si_result1))
+ {
#ifdef DEBUG
- printf("Error: char first match result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, si result does not match expected result\n",
+ len);
+ print_si (vec_si_expected1, vec_si_result1);
#else
- abort();
+ abort();
#endif
+ }
+
+ len = 8;
+ vec_si_expected1 = (vector signed int){ -30, -10, 0, 0 };
+ store_data_si = (vector signed int){ -30, -10, 0, 10 };
+ vec_si_result1 = (vector signed int){ 0, 0, 0, 0};
- char_src1 = (vector signed char) {-1, 2, 3, 0, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {2, 3, 20, 0, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 3;
+ address_si = &vec_si_result1[0];
- result = vec_first_match_or_eos_index (char_src1, char_src2);
+ vec_xst_len (store_data_si, address_si, len);
- if (result != expected_result)
+ if (result_wrong_si (vec_si_expected1, vec_si_result1))
+ {
#ifdef DEBUG
- printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, si result does not match expected result\n",
+ len);
+ print_si (vec_si_expected1, vec_si_result1);
#else
- abort();
+ abort();
#endif
+ }
+
+ len = 16;
+ vec_sll_expected1 = (vector signed long long int){ -3000, 10000 };
+ store_data_sll = (vector signed long long int){ -3000, 10000 };
+ vec_sll_result1 = (vector signed long long int){ 0, 0};
- char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {-1, -2, -3, -4, -5, -6, -7, -8,
- -9, -10, -11, -12, -13, -14, -15, -16};
- expected_result = 16;
+ address_sll = (signed long long *)&vec_sll_result1[0];
- result = vec_first_match_or_eos_index (char_src1, char_src2);
+ vec_xst_len (store_data_sll, address_sll, len);
- if (result != expected_result)
+ if (result_wrong_sll (vec_sll_expected1, vec_sll_result1) == TRUE)
+ {
#ifdef DEBUG
- printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, sll result does not match expected result\n",
+ len);
+ print_sll (vec_sll_expected1, vec_sll_result1);
#else
- abort();
-#endif
+ abort();
#endif
+ }
- uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {-1, 0, -3, -4, -5, -6, -7, -8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 1;
+ len = 8;
+ vec_sll_expected1 = (vector signed long long int){ -3000, 0 };
+ store_data_sll = (vector signed long long int){ -3000, 10000 };
+ vec_sll_result1 = (vector signed long long int){ 0, 0};
- result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
+ address_sll = (signed long long *)&vec_sll_result1[0];
- if (result != expected_result)
+ vec_xst_len (store_data_sll, address_sll, len);
+
+ if (result_wrong_sll (vec_sll_expected1, vec_sll_result1))
+ {
#ifdef DEBUG
- printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, sll result does not match expected result\n",
+ len);
+ print_sll (vec_sll_expected1, vec_sll_result1);
#else
abort();
#endif
+ }
+
+ len = 16;
+ vec_ull_expected1 = (vector unsigned long long int){ 50000, 120000 };
+ store_data_ull = (vector unsigned long long int){ 50000, 120000 };
+ vec_ull_result1 = (vector unsigned long long int){ 0, 0};
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17};
- uchar_src2 = (vector unsigned char) {3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18};
- expected_result = 16;
+ address_ull = (unsigned long long *) &vec_ull_result1[0];
- result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
+ vec_xst_len (store_data_ull, address_ull, len);
- if (result != expected_result)
+ if (result_wrong_ull (vec_ull_expected1, vec_ull_result1))
+ {
#ifdef DEBUG
- printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, ull result does not match expected result\n",
+ len);
+ print_ull (vec_ull_expected1, vec_ull_result1);
#else
- abort();
+ abort();
#endif
+ }
- /* short int */
- short_src1 = (vector short int) {10, -20, -30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
+ len = 8;
+ vec_ull_expected1 = (vector unsigned long long int){ 50000, 0 };
+ store_data_ull = (vector unsigned long long int){ 50000, 120000 };
+ vec_ull_result1 = (vector unsigned long long int){ 0, 0};
- expected_result = 3;
+ address_ull = (unsigned long long *) &vec_ull_result1[0];
- result = vec_first_match_or_eos_index (short_src1, short_src2);
+ vec_xst_len (store_data_ull, address_ull, len);
- if (result != expected_result)
+ if (result_wrong_ull (vec_ull_expected1, vec_ull_result1))
+ {
#ifdef DEBUG
- printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, ull result does not match expected result\n",
+ len);
+ print_ull (vec_ull_expected1, vec_ull_result1);
#else
- abort();
+ abort();
#endif
+ }
- short_src1 = (vector short int) {1, 20, 30, 40, 50, 60, 70, 80};
+ len = 16;
+ vec_s128_expected1 = (vector __int128_t){ 12345 };
+ store_data_s128 = (vector __int128_t){ 12345 };
- short_src2 = (vector short int) {10, 0, 30, 40, 50, 60, 70, 80};
+ vec_s128_result1[0] = 0;
- expected_result = 1;
+ address_s128 = (__int128_t *)(&vec_s128_result1[0]);
- result = vec_first_match_or_eos_index (short_src1, short_src2);
+ vec_xst_len (store_data_s128, address_s128, len);
- if (result != expected_result)
+ if (result_wrong_s128 (vec_s128_expected1, vec_s128_result1))
#ifdef DEBUG
- printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ {
+ printf("Error: vec_xst_len, len = %d, s128, result does not match expected result\n",
+ len);
+ print_s128 (vec_s128_expected1, vec_s128_result1);
+ }
#else
- abort();
+ abort();
#endif
- short_src1 = (vector short int) {-10, -20, -30, -40, -50, -60, -70, -80};
+ len = 16;
+ vec_u128_expected1 = (vector __uint128_t){ 12345 };
+ store_data_u128 = (vector __uint128_t){ 12345 };
- short_src2 = (vector short int) {10, 20, 30, 40, 50, 0, 70, 80};
+ vec_u128_result1[0] = 0;
- expected_result = 5;
+ address_u128 = (__int128_t *)(&vec_u128_result1[0]);
- result = vec_first_match_or_eos_index (short_src1, short_src2);
+ vec_xst_len (store_data_u128, address_u128, len);
- if (result != expected_result)
+ if (result_wrong_u128 (vec_u128_expected1, vec_u128_result1))
+ {
#ifdef DEBUG
- printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, u128, result does not match expected result\n", len);
+ print_u128 (vec_u128_expected1, vec_u128_result1);
#else
abort();
#endif
+ }
- short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {0, 0, 0, 0, 0, 0, 0, 0};
+ len = 16;
+ vec_d_expected1 = (vector double){ 1., 2. };
+ store_data_d = (vector double){ 1., 2. };
+ vec_d_result1 = (vector double){ 0., 0. };
- expected_result = 0;
+ address_d = (double *)(&vec_d_result1[0]);
- result = vec_first_match_or_eos_index (short_src1, short_src2);
+ vec_xst_len (store_data_d, address_d, len);
- if (result != expected_result)
+ if (result_wrong_d (vec_d_expected1, vec_d_result1))
+ {
#ifdef DEBUG
- printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, double, result does not match expected result\n",
+ len);
+ print_d (vec_d_expected1, vec_d_result1);
#else
- abort();
+ abort();
#endif
+ }
- ushort_src1 = (vector short unsigned int) {1, 2, 0, 0, 60, 70, 0};
- ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
+ len = 8;
+ vec_d_expected1 = (vector double){ 1., 0. };
+ store_data_d = (vector double){ 1., 2. };
+ vec_d_result1 = (vector double){ 0., 0. };
- expected_result = 2;
+ address_d = (double *)(&vec_d_result1[0]);
- result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
+ vec_xst_len (store_data_d, address_d, len);
- if (result != expected_result)
+ if (result_wrong_d (vec_d_expected1, vec_d_result1))
+ {
#ifdef DEBUG
- printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, double, result does not match expected result\n",
+ len);
+ print_d (vec_d_expected1, vec_d_result1);
#else
- abort();
+ abort();
#endif
+ }
- ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
- 60, -70, 80, -90};
- ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
- -60, 70, -80, 90};
+ len = 16;
+ vec_f_expected1 = (vector float){ 1., 2., 3., 4. };
+ store_data_f = (vector float){ 1., 2., 3., 4. };
+ vec_f_result1 = (vector float){ 0., 0., 0., 0. };
- expected_result = 8;
+ address_f = (float *)(&vec_f_result1[0]);
- result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
+ vec_xst_len (store_data_f, address_f, len);
- if (result != expected_result)
+ if (result_wrong_f (vec_f_expected1, vec_f_result1))
+ {
#ifdef DEBUG
- printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, float, result does not match expected result\n",
+ len);
+ print_f (vec_f_expected1, vec_f_result1);
#else
- abort();
+ abort();
#endif
- ushort_src1 = (vector short unsigned int) {-20, 30, -40, 50,
- 60, -70, 80, 0};
+ }
- ushort_src2 = (vector short unsigned int) {20, -30, 40, -50,
- -60, 70, -80, 90};
+ len = 4;
+ vec_f_expected1 = (vector float){ 1., 0., 0., 0. };
+ store_data_f = (vector float){ 1., 2., 3., 4. };
+ vec_f_result1 = (vector float){ 0., 0., 0., 0. };
- expected_result = 7;
+ address_f = (float *)(&vec_f_result1[0]);
- result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
+ vec_xst_len (store_data_f, address_f, len);
- if (result != expected_result)
+ if (result_wrong_f (vec_f_expected1, vec_f_result1))
+ {
#ifdef DEBUG
- printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xst_len, len = %d, float, result does not match expected result\n",
+ len);
+ print_f (vec_f_expected1, vec_f_result1);
#else
- abort();
+ abort();
#endif
+ }
- /* int */
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {10, 20, 30, 4};
-
- expected_result = 3;
+ /* vec_xl_len() tests */
+ for (i = 0; i < 100; i++)
+ {
+ data_c[i] = i;
+ data_uc[i] = i+1;
+ data_ssi[i] = i+10;
+ data_usi[i] = i+11;
+ data_si[i] = i+100;
+ data_ui[i] = i+101;
+ data_sll[i] = i+1000;
+ data_ull[i] = i+1001;
+ data_f[i] = i+100000.0;
+ data_d[i] = i+1000000.0;
+ data_128[i] = i + 12800000;
+ data_u128[i] = i + 12800001;
+ }
- result = vec_first_match_or_eos_index (int_src1, int_src2);
+ len = 16;
+ vec_sc_expected1 = (vector signed char){0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15};
+ vec_sc_result1 = vec_xl_len (data_c, len);
- if (result != expected_result)
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_sc_result1[i] != vec_sc_expected1[i])
#ifdef DEBUG
- printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_sc_result1[%d] = %d; vec_sc_expected1[%d] = %d\n",
+ len, i, vec_sc_result1[i], i, vec_sc_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- int_src1 = (vector int) {0, 2, 3, 4};
- int_src2 = (vector int) {4, 3, 2, 1};
+ len = 12;
- expected_result = 0;
+ vec_sc_expected1 = (vector signed char){0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 0, 0, 0, 0};
+ vec_sc_result1 = vec_xl_len (data_c, len);
- result = vec_first_match_or_eos_index (int_src1, int_src2);
-
- if (result != expected_result)
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_sc_result1[i] != vec_sc_expected1[i])
#ifdef DEBUG
- printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_sc_result1[%d] = %d; vec_sc_expected1[%d] = %d\n",
+ len, i, vec_sc_result1[i], i, vec_sc_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
+ len = 16;
+ vec_uc_expected1 = (vector unsigned char){1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16};
+ vec_uc_result1 = vec_xl_len (data_uc, len);
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {4, 3, 2, 1};
-
- expected_result = 4;
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_uc_result1[i] != vec_uc_expected1[i])
+#ifdef DEBUG
+ printf("Error: vec_xl_len(), len = %d, vec_uc_result1[%d] = %d; vec_uc_expected1[%d] = %d\n",
+ len, i, vec_uc_result1[i], i, vec_uc_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_match_or_eos_index (int_src1, int_src2);
+ len = 12;
+ vec_uc_expected1 = (vector unsigned char){1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 0, 0, 0, 0};
+ vec_uc_result1 = vec_xl_len (data_uc, len);
- if (result != expected_result)
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_uc_result1[i] != vec_uc_expected1[i])
#ifdef DEBUG
- printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_uc_result1[%d] = %d; vec_uc_expected1[%d] = %d\n",
+ len, i, vec_uc_result1[i], i, vec_uc_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {11, 2, 33, 4};
+ len = 16;
+ vec_ss_expected1 = (vector signed short){10, 11, 12, 13, 14, 15, 16, 17};
- expected_result = 1;
+ vec_ss_result1 = vec_xl_len (data_ssi, len);
- result = vec_first_match_or_eos_index (uint_src1, uint_src2);
-
- if (result != expected_result)
+ for (i = 0; i < 8; i++)
+ {
+ if (vec_ss_result1[i] != vec_ss_expected1[i])
#ifdef DEBUG
- printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_ss_result1[%d] = %d; vec_ss_expected1[%d] = %d\n",
+ len, i, vec_ss_result1[i], i, vec_ss_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uint_src1 = (vector unsigned int) {1, 2, 0, 4};
- uint_src2 = (vector unsigned int) {2, 3, 4, 5};
+ len = 8;
+ vec_ss_expected1 = (vector signed short){10, 11, 12, 13, 0, 0, 0, 0};
- expected_result = 2;
+ vec_ss_result1 = vec_xl_len (data_ssi, len);
- result = vec_first_match_or_eos_index (uint_src1, uint_src2);
-
- if (result != expected_result)
+ for (i = 0; i < 8; i++)
+ {
+ if (vec_ss_result1[i] != vec_ss_expected1[i])
#ifdef DEBUG
- printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_ss_result1[%d] = %d; vec_ss_expected1[%d] = %d\n",
+ len, i, vec_ss_result1[i], i, vec_ss_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {2, 3, 4, 5};
+ len = 16;
+ vec_us_expected1 = (vector unsigned short){11, 12, 13, 14, 15, 16, 17, 18};
+ vec_us_result1 = vec_xl_len (data_usi, len);
- expected_result = 4;
-
- result = vec_first_match_or_eos_index (uint_src1, uint_src2);
-
- if (result != expected_result)
+ for (i = 0; i < 8; i++)
+ {
+ if (vec_us_result1[i] != vec_us_expected1[i])
#ifdef DEBUG
- printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_us_result1[%d] = %d; vec_us_expected1[%d] = %d\n",
+ len, i, vec_us_result1[i], i, vec_us_expected1[i]);
#else
- abort();
+ abort ();
#endif
- /* Tests for: vec_first_mismatch_or_eos_index() */
- /* char */
- char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {-1, 2, 3, 20, -5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 3;
+ }
- result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
+ len = 8;
+ vec_us_expected1 = (vector unsigned short){11, 12, 13, 14, 0, 0, 0, 0};
+ vec_us_result1 = vec_xl_len (data_usi, len);
- if (result != expected_result)
+ for (i = 0; i < 8; i++)
+ {
+ if (vec_us_result1[i] != vec_us_expected1[i])
#ifdef DEBUG
- printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_us_result1[%d] = %d; vec_us_expected1[%d] = %d\n",
+ len, i, vec_us_result1[i], i, vec_us_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- char_src1 = (vector signed char) {1, 2, 0, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {1, 2, 0, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 2;
-
- result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
+ len = 16;
+ vec_si_result1 = vec_xl_len (data_si, len);
+ vec_si_expected1 = (vector int){100, 101, 102, 103};
- if (result != expected_result)
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_si_result1[i] != vec_si_expected1[i])
#ifdef DEBUG
- printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_si_result1[%d] = %d; vec_si_expected1[%d] = %d\n",
+ len, i, vec_si_result1[i], i, vec_si_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- char_src1 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- char_src2 = (vector signed char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 16;
-
- result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
+ len = 8;
+ vec_si_result1 = vec_xl_len (data_si, len);
+ vec_si_expected1 = (vector int){100, 101, 0, 0};
- if (result != expected_result)
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_si_result1[i] != vec_si_expected1[i])
#ifdef DEBUG
- printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_si_result1[%d] = %d; vec_si_expected1[%d] = %d\n",
+ len, i, vec_si_result1[i], i, vec_si_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {1, 0, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16};
- expected_result = 1;
-
- result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
+ len = 16;
+ vec_ui_result1 = vec_xl_len (data_ui, len);
+ vec_ui_expected1 = (vector unsigned int){101, 102, 103, 104};
- if (result != expected_result)
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_ui_result1[i] != vec_ui_expected1[i])
#ifdef DEBUG
- printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_ui_result1[%d] = %d; vec_ui_expected1[%d] = %d\n",
+ len, i, vec_ui_result1[i], i, vec_ui_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 0, 11, 12, 13, 14, 15, 16};
- uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 0, 11, 12, 13, 14, 15, 16};
- expected_result = 8;
-
- result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
+ len = 8;
+ vec_ui_result1 = vec_xl_len (data_ui, len);
+ vec_ui_expected1 = (vector unsigned int){101, 102, 0, 0};
- if (result != expected_result)
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_ui_result1[i] != vec_ui_expected1[i])
#ifdef DEBUG
- printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_ui_result1[%d] = %d; vec_ui_expected1[%d] = %d\n",
+ len, i, vec_ui_result1[i], i, vec_ui_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17};
- uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 0, 16, 17};
- expected_result = 13;
-
- result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
+ len = 16;
+ vec_sll_result1 = vec_xl_len (data_sll, len);
+ vec_sll_expected1 = (vector signed long long){1000, 1001};
- if (result != expected_result)
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_sll_result1[i] != vec_sll_expected1[i])
#ifdef DEBUG
- printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_sll_result1[%d] = %lld; vec_sll_expected1[%d] = %lld\n",
+ len, i, vec_sll_result1[i], i, vec_sll_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17};
- uchar_src2 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14, 15, 16, 17};
- expected_result = 16;
-
- result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
+ len = 8;
+ vec_sll_result1 = vec_xl_len (data_sll, len);
+ vec_sll_expected1 = (vector signed long long){1000, 0};
- if (result != expected_result)
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_sll_result1[i] != vec_sll_expected1[i])
#ifdef DEBUG
- printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_sll_result1[%d] = %lld; vec_sll_expected1[%d] = %lld\n",
+ len, i, vec_sll_result1[i], i, vec_sll_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- /* short int */
- short_src1 = (vector short int) {-10, -20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {-10, 20, 30, 40, 50, 60, 70, 80};
+ len = 16;
+ vec_ull_result1 = vec_xl_len (data_ull, len);
+ vec_ull_expected1 = (vector unsigned long long){1001, 1002};
- expected_result = 1;
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_ull_result1[i] != vec_ull_expected1[i])
+#ifdef DEBUG
+ printf("Error: vec_xl_len(), len = %d, vec_ull_result1[%d] = %lld; vec_ull_expected1[%d] = %lld\n",
+ len, i, vec_ull_result1[i], i, vec_ull_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
+ len = 8;
+ vec_ull_result1 = vec_xl_len (data_ull, len);
+ vec_ull_expected1 = (vector unsigned long long){1001, 0};
- if (result != expected_result)
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_ull_result1[i] != vec_ull_expected1[i])
#ifdef DEBUG
- printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_ull_result1[%d] = %lld; vec_ull_expected1[%d] = %lld\n",
+ len, i, vec_ull_result1[i], i, vec_ull_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- short_src1 = (vector short int) {0, 20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {0, 20, 30, 40, 50, 60, 70, 80};
+ len = 16;
+ vec_f_result1 = vec_xl_len (data_f, len);
+ vec_f_expected1 = (vector float){100000.0, 100001.0, 100002.0, 100003.0};
- expected_result = 0;
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_f_result1[i] != vec_f_expected1[i])
+#ifdef DEBUG
+ printf("Error: vec_xl_len(), len = %d, vec_f_result1[%d] = %f; vec_f_expected1[%d] = %f\n",
+ len, i, vec_f_result1[i], i, vec_f_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
+ len = 8;
+ vec_f_result1 = vec_xl_len (data_f, len);
+ vec_f_expected1 = (vector float){100000.0, 100001.0, 0.0, 0.0};
- if (result != expected_result)
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_f_result1[i] != vec_f_expected1[i])
#ifdef DEBUG
- printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_f_result1[%d] = %f; vec_f_expected1[%d] = %f\n",
+ len, i, vec_f_result1[i], i, vec_f_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- short_src1 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {10, 20, 30, 40, 50, 60, 70, 80};
+ len = 16;
+ vec_d_result1 = vec_xl_len (data_d, len);
+ vec_d_expected1 = (vector double){1000000.0, 1000001.0};
- expected_result = 8;
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_d_result1[i] != vec_d_expected1[i])
+#ifdef DEBUG
+ printf("Error: vec_xl_len(), len = %d, vec_d_result1[%d] = %f; vec_f_expected1[%d] = %f\n",
+ len, i, vec_d_result1[i], i, vec_d_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
+ len = 8;
+ vec_d_result1 = vec_xl_len (data_d, len);
+ vec_d_expected1 = (vector double){1000000.0, 0.0};
- if (result != expected_result)
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_d_result1[i] != vec_d_expected1[i])
#ifdef DEBUG
- printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: vec_xl_len(), len = %d, vec_d_result1[%d] = %f; vec_f_expected1[%d] = %f\n",
+ len, i, vec_d_result1[i], i, vec_d_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- short_src1 = (vector short int) {10, 0, 30, 40, 50, 60, 70, 80};
- short_src2 = (vector short int) {10, 0, 30, 40, 50, 60, 70, 80};
-
- expected_result = 1;
+ vec_s128_expected1 = (vector __int128_t){12800000};
+ vec_s128_result1 = vec_xl_len (data_128, len);
- result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
+ if (vec_s128_expected1[0] != vec_s128_result1[0])
+ {
+#ifdef DEBUG
+ printf("Error: vec_xl_len(), len = %d, vec_s128_result1[0] = %lld %llu; ",
+ len, vec_s128_result1[0] >> 64,
+ vec_s128_result1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+ printf("vec_s128_expected1[0] = %lld %llu\n",
+ vec_s128_expected1[0] >> 64,
+ vec_s128_expected1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+#else
+ abort ();
+#endif
+ }
- if (result != expected_result)
+ vec_u128_result1 = vec_xl_len (data_u128, len);
+ vec_u128_expected1 = (vector __uint128_t){12800001};
+ if (vec_u128_expected1[0] != vec_u128_result1[0])
#ifdef DEBUG
- printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ {
+ printf("Error: vec_xl_len(), len = %d, vec_u128_result1[0] = %lld; ",
+ len, vec_u128_result1[0] >> 64,
+ vec_u128_result1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+ printf("vec_u128_expected1[0] = %lld\n",
+ vec_u128_expected1[0] >> 64,
+ vec_u128_expected1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+ }
#else
- abort();
+ abort ();
#endif
- ushort_src1 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 0};
- ushort_src2 = (vector short unsigned int) {10, 20, 30, 40, 50, 60, 70, 80};
+ /* Tests to ensure the vec_xl_len() is properly optimized with a pre
+ and post data initialization is done. */
- expected_result = 7;
+ len = 16;
- result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
+ vec_sc_expected1 = (vector signed char){ 1, 2, 3, 4, 5, 6, 7, 8,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
- if (result != expected_result)
+ input_c = (vector signed char){ 1, 2, 3, 4, 5, 6, 7, 8,
+ 0, 0, 0, 0, 0, 0, 0, 0 };
+ vec_sc_result1 = vec_xl_len (&input_c[0], len);
+ input_c = (vector signed char){ 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24 };
+
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_sc_result1[i] != vec_sc_expected1[i])
#ifdef DEBUG
- printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_sc_result1[%d] = %d; vec_sc_expected1[%d] = %d\n",
+ len, i, vec_sc_result1[i], i, vec_sc_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- ushort_src1 = (vector short unsigned int) {20, 0, 40, 50, 60, 70, 80, 90};
- ushort_src2 = (vector short unsigned int) {20, 0, 40, 50, 60, 70, 80, 90};
-
- expected_result = 1;
-
- result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
+ len = 16;
+ vec_uc_expected1 = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16 };
+ input_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16 };
+ vec_uc_result1 = vec_xl_len (&input_uc[0], len);
+ input_uc = (vector unsigned char){ 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24 };
- if (result != expected_result)
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_uc_result1[i] != vec_uc_expected1[i])
#ifdef DEBUG
- printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_uc_result1[%d] = %d; vec_uc_expected1[%d] = %d\n",
+ len, i, vec_uc_result1[i], i, vec_uc_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- ushort_src1 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
- ushort_src2 = (vector short unsigned int) {20, 30, 40, 50, 60, 70, 80, 90};
+ len = 16;
+ vec_ss_expected1 = (vector signed short){ 10, 11, 12, 13, 14, 15, 16, 17 };
+ input_ssi = (vector signed short){ 10, 11, 12, 13, 14, 15, 16, 17 };
+ vec_ss_result1 = vec_xl_len (&input_ssi[0], len);
+ input_ssi = (vector signed short){ 14, 15, 16, 17, 18, 19, 20, 21 };
- expected_result = 8;
+ for (i = 0; i < 8; i++)
+ {
+ if (vec_ss_result1[i] != vec_ss_expected1[i])
+#ifdef DEBUG
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_ss_result1[%d] = %d; vec_ss_expected1[%d] = %d\n",
+ len, i, vec_ss_result1[i], i, vec_ss_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
+ len = 16;
+ vec_us_expected1 = (vector unsigned short){ 11, 12, 13, 14, 15, 16, 17, 18 };
+ input_usi = (vector unsigned short){ 11, 12, 13, 14, 15, 16, 17, 18 };
+ vec_us_result1 = vec_xl_len (&input_usi[0], len);
+ input_usi = (vector unsigned short){ 15, 16, 17, 18, 19, 20, 21, 22 };
- if (result != expected_result)
+ for (i = 0; i < 8; i++)
+ {
+ if (vec_us_result1[i] != vec_us_expected1[i])
#ifdef DEBUG
- printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_us_result1[%d] = %d; vec_us_expected1[%d] = %d\n",
+ len, i, vec_us_result1[i], i, vec_us_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- /* int */
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {1, 20, 3, 4};
+ len = 16;
+ vec_si_expected1 = (vector int){ 100, 101, 102, 103 };
+ input_si = (vector int){ 100, 101, 102, 103 };
+ vec_si_result1 = vec_xl_len (&input_si[0], len);
+ input_si = (vector int){ 102, 103, 104, 105 };
- expected_result = 1;
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_si_result1[i] != vec_si_expected1[i])
+#ifdef DEBUG
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_si_result1[%d] = %d; vec_si_expected1[%d] = %d\n",
+ len, i, vec_si_result1[i], i, vec_si_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
+ len = 16;
+ vec_ui_expected1 = (vector unsigned int){101, 102, 103, 104};
+ input_ui = (vector unsigned int){101, 102, 103, 104};
+ vec_ui_result1 = vec_xl_len (&input_ui[0], len);
+ input_ui = (vector unsigned int){ 103, 104, 105, 106 };
- if (result != expected_result)
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_ui_result1[i] != vec_ui_expected1[i])
#ifdef DEBUG
- printf("Error: int first mismatch or EOS result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_ui_result1[%d] = %d; vec_ui_expected1[%d] = %d\n",
+ len, i, vec_ui_result1[i], i, vec_ui_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- int_src1 = (vector int) {1, 2, 3, 4};
- int_src2 = (vector int) {1, 2, 3, 4};
+#if 1
+ len = 16;
+ vec_sll_expected1 = (vector signed long long){1000, 1001};
+ input_sll = (vector signed long long ){1000, 1001};
+ vec_sll_result1 = vec_xl_len ((signed long long int *)&input_sll[0], len);
+ input_sll = (vector signed long long){1001, 1002};
- expected_result = 4;
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_sll_result1[i] != vec_sll_expected1[i])
+#ifdef DEBUG
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_sll_result1[%d] = %lld; vec_sll_expected1[%d] = %lld\n",
+ len, i, vec_sll_result1[i], i, vec_sll_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
+ len = 16;
+ vec_ull_expected1 = (vector unsigned long long int){1001, 1002};
+ input_ull = (vector unsigned long long int){1001, 1002};
+ vec_ull_result1 = vec_xl_len ((unsigned long long int *)&input_ull[0], len);
+ input_ull = (vector unsigned long long int){1002, 1003};
- if (result != expected_result)
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_ull_result1[i] != vec_ull_expected1[i])
#ifdef DEBUG
- printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_ull_result1[%d] = %lld; vec_ull_expected1[%d] = %lld\n",
+ len, i, vec_ull_result1[i], i, vec_ull_expected1[i]);
#else
- abort();
+ abort ();
+#endif
+ }
#endif
- int_src1 = (vector int) {1, 2, 0, 4};
- int_src2 = (vector int) {1, 2, 0, 4};
+
+ len = 16;
+ vec_f_expected1 = (vector float){100000.0, 100001.0, 100002.0, 100003.0};
+ input_f = (vector float){100000.0, 100001.0, 100002.0, 100003.0};
+ vec_f_result1 = vec_xl_len (&input_f[0], len);
+ input_f = (vector float){100001.0, 100002.0, 100003.0, 100004.0};
- expected_result = 2;
+ for (i = 0; i < 4; i++)
+ {
+ if (vec_f_result1[i] != vec_f_expected1[i])
+#ifdef DEBUG
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_f_result1[%d] = %f; vec_f_expected1[%d] = %f\n",
+ len, i, vec_f_result1[i], i, vec_f_expected1[i]);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
+ len = 16;
+ vec_d_expected1 = (vector double){1000000.0, 1000001.0};
+ input_d = (vector double){1000000.0, 1000001.0};
+ vec_d_result1 = vec_xl_len (&input_d[0], len);
+ input_d = (vector double){1000001.0, 1000002.0};
- if (result != expected_result)
+ for (i = 0; i < 2; i++)
+ {
+ if (vec_d_result1[i] != vec_d_expected1[i])
#ifdef DEBUG
- printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_d_result1[%d] = %f; vec_f_expected1[%d] = %f\n",
+ len, i, vec_d_result1[i], i, vec_d_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
- int_src1 = (vector int) {1, 0, 3, 4};
- int_src2 = (vector int) {1, 2, 3, 4};
+ len = 16;
+ vec_s128_expected1 = (vector __int128_t){12800000};
+ input_128 = (vector __int128_t){12800000};
+ vec_s128_result1 = vec_xl_len (&input_128[0], len);
+ input_128 = (vector __int128_t){12345678};
- expected_result = 1;
+ if (vec_s128_expected1[0] != vec_s128_result1[0])
+ {
+#ifdef DEBUG
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_s128_result1[0] = %lld %llu; ",
+ len, vec_s128_result1[0] >> 64,
+ vec_s128_result1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+ printf("vec_s128_expected1[0] = %lld %llu\n",
+ vec_s128_expected1[0] >> 64,
+ vec_s128_expected1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+#else
+ abort ();
+#endif
+ }
- result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
+ len = 16;
+ vec_u128_expected1 = (vector __uint128_t){12800001};
+ input_u128 = (vector __uint128_t){12800001};
+ vec_u128_result1 = vec_xl_len (&input_u128[0], len);
+ input_u128 = (vector __uint128_t){98765432};
- if (result != expected_result)
+ if (vec_u128_expected1[0] != vec_u128_result1[0])
#ifdef DEBUG
- printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ {
+ printf("Error: pre/post initialzation vec_xl_len(), len = %d, vec_u128_result1[0] = %lld; ",
+ len, vec_u128_result1[0] >> 64,
+ vec_u128_result1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+ printf("vec_u128_expected1[0] = %lld\n",
+ vec_u128_expected1[0] >> 64,
+ vec_u128_expected1[0] & (__int128_t)0xFFFFFFFFFFFFFFFF);
+ }
#else
- abort();
+ abort ();
#endif
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {11, 2, 33, 4};
+ /* Tests to ensure the vec_xl_len_r() is properly optimized with a pre
+ and post data initialization is done. */
- expected_result = 0;
+ len = 16;
+ vec_uc_expected1 = (vector unsigned char){ 16,15, 14, 13, 12, 11, 10, 9,
+ 8, 7, 6, 5, 4, 3, 2, 1 };
+ input_uc = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16 };
+ vec_uc_result1 = vec_xl_len_r (&input_uc[0], len);
+ input_uc = (vector unsigned char){ 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24 };
- result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
-
- if (result != expected_result)
+ for (i = 0; i < 16; i++)
+ {
+ if (vec_uc_result1[i] != vec_uc_expected1[i])
#ifdef DEBUG
- printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
+ printf("Error: pre/post initialzation vec_xl_len_r(), len = %d, vec_uc_result1[%d] = %d; vec_uc_expected1[%d] = %d\n",
+ len, i, vec_uc_result1[i], i, vec_uc_expected1[i]);
#else
- abort();
+ abort ();
#endif
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- uint_src1 = (vector unsigned int) {1, 2, 3, 0};
- uint_src2 = (vector unsigned int) {1, 2, 3, 0};
- expected_result = 3;
- result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
- uint_src1 = (vector unsigned int) {1, 2, 3, 4};
- uint_src2 = (vector unsigned int) {1, 2, 3, 4};
- expected_result = 4;
- result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
- if (result != expected_result)
-#ifdef DEBUG
- printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
- result, expected_result);
-#else
- abort();
-#endif
-}