vsx.md (first_match_index_<mode>): Calculate index using natural element order.
authorCarl Love <cel@us.ibm.com>
Wed, 6 Jun 2018 23:16:06 +0000 (23:16 +0000)
committerCarl Love <carll@gcc.gnu.org>
Wed, 6 Jun 2018 23:16:06 +0000 (23:16 +0000)
gcc/ChangeLog:

2018-06-04  Carl Love  <cel@us.ibm.com>

* gcc/config/rs6000/vsx.md (first_match_index_<mode>): Calculate index
using natural element order.  Use gen_lshrsi3 instead of gen_ashrsi3
as it is slightly cheaper.
(first_match_or_eos_index_<mode>):
Calculate index using natural element order.
(first_match_index_<mode>):
Calculate index using natural element order.
(first_match_or_eos_index_<mode>):
Calculate index using natural order.
(define_insn vclzlsbb): Change to define_insn vclzlsbb_<mode>.
for BE and LE modes.
* gcc/config/rs6000/rs6000-c.c: Rename P9V_BUILTIN_VCLZLSBB,
P9V_BUILTIN_VCLZLSBB_V16QI.
* gcc/config/rs6000/rs6000-builtin.def: Make VCLZLSBB mode
specific.

gcc/testsuite/ChangeLog:

2018-06-04  Carl Love  <cel@us.ibm.com>

* gcc.target/powerpc/builtins-8-p9-runnable.c: Add additional
debug print statements.  Fix a few formating issues.

From-SVN: r261255

gcc/ChangeLog
gcc/config/rs6000/rs6000-builtin.def
gcc/config/rs6000/rs6000-c.c
gcc/config/rs6000/vsx.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/builtins-8-p9-runnable.c

index ab526f9..4eaaa70 100644 (file)
@@ -1,3 +1,21 @@
+2018-06-04  Carl Love  <cel@us.ibm.com>
+
+       * gcc/config/rs6000/vsx.md (first_match_index_<mode>): Calculate index
+       using natural element order.  Use gen_lshrsi3 instead of gen_ashrsi3
+       as it is slightly cheaper.
+       (first_match_or_eos_index_<mode>):
+       Calculate index using natural element order.
+       (first_match_index_<mode>):
+       Calculate index using natural element order.
+       (first_match_or_eos_index_<mode>):
+       Calculate index using natural order.
+       (define_insn vclzlsbb): Change to define_insn vclzlsbb_<mode>.
+       for BE and LE modes.
+       * gcc/config/rs6000/rs6000-c.c: Rename P9V_BUILTIN_VCLZLSBB,
+       P9V_BUILTIN_VCLZLSBB_V16QI.
+       * gcc/config/rs6000/rs6000-builtin.def: Make VCLZLSBB mode
+       specific.
+
 2018-06-06  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        * doc/extend.texi (PowerPC AltiVec Built-in Functions): Adjust
index 98702c7..f799681 100644 (file)
@@ -2214,7 +2214,9 @@ BU_P9V_64BIT_AV_X (STXVL, "stxvl",        MISC)
 BU_P9V_64BIT_AV_X (XST_LEN_R,  "xst_len_r",    MISC)
 
 /* 1 argument vector functions added in ISA 3.0 (power9). */
-BU_P9V_AV_1 (VCLZLSBB, "vclzlsbb",             CONST,  vclzlsbb)
+BU_P9V_AV_1 (VCLZLSBB_V16QI, "vclzlsbb_v16qi", CONST,  vclzlsbb_v16qi)
+BU_P9V_AV_1 (VCLZLSBB_V8HI, "vclzlsbb_v8hi",   CONST,  vclzlsbb_v8hi)
+BU_P9V_AV_1 (VCLZLSBB_V4SI, "vclzlsbb_v4si",   CONST,  vclzlsbb_v4si)
 BU_P9V_AV_1 (VCTZLSBB_V16QI, "vctzlsbb_v16qi", CONST,  vctzlsbb_v16qi)
 BU_P9V_AV_1 (VCTZLSBB_V8HI, "vctzlsbb_v8hi",   CONST,  vctzlsbb_v8hi)
 BU_P9V_AV_1 (VCTZLSBB_V4SI, "vctzlsbb_v4si",   CONST,  vctzlsbb_v4si)
index 2ef6f7b..08326c2 100644 (file)
@@ -5437,9 +5437,9 @@ const struct altivec_builtin_types altivec_overloaded_builtins[] = {
     RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI,
     RS6000_BTI_unsigned_V4SI, 0 },
 
-  { P9V_BUILTIN_VEC_VCLZLSBB, P9V_BUILTIN_VCLZLSBB,
+  { P9V_BUILTIN_VEC_VCLZLSBB, P9V_BUILTIN_VCLZLSBB_V16QI,
     RS6000_BTI_INTSI, RS6000_BTI_V16QI, 0, 0 },
-  { P9V_BUILTIN_VEC_VCLZLSBB, P9V_BUILTIN_VCLZLSBB,
+  { P9V_BUILTIN_VEC_VCLZLSBB, P9V_BUILTIN_VCLZLSBB_V16QI,
     RS6000_BTI_INTSI, RS6000_BTI_unsigned_V16QI, 0, 0 },
 
   { P9V_BUILTIN_VEC_VCTZLSBB, P9V_BUILTIN_VCTZLSBB_V16QI,
index 58796ff..0e016fe 100644 (file)
   "vcmpnez<VSX_EXTRACT_WIDTH>. %0,%1,%2"
   [(set_attr "type" "vecsimple")])
 
-;; Return first position of match between vectors
+;; Return first position of match between vectors using natural order
+;; for both LE and BE execution modes.
 (define_expand "first_match_index_<mode>"
   [(match_operand:SI 0 "register_operand")
    (unspec:SI [(match_operand:VSX_EXTRACT_I 1 "register_operand")
   sh = GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) / 2;
 
   if (<MODE>mode == V16QImode)
-    emit_insn (gen_vctzlsbb_<mode> (operands[0], not_result));
+    {
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (operands[0], not_result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (operands[0], not_result));
+    }
   else
     {
       rtx tmp = gen_reg_rtx (SImode);
-      emit_insn (gen_vctzlsbb_<mode> (tmp, not_result));
-      emit_insn (gen_ashrsi3 (operands[0], tmp, GEN_INT (sh)));
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (tmp, not_result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (tmp, not_result));
+      emit_insn (gen_lshrsi3 (operands[0], tmp, GEN_INT (sh)));
     }
   DONE;
 })
 
-;; Return first position of match between vectors or end of string (EOS)
+;; Return first position of match between vectors or end of string (EOS) using
+;; natural element order for both LE and BE execution modes.
 (define_expand "first_match_or_eos_index_<mode>"
   [(match_operand:SI 0 "register_operand")
    (unspec: SI [(match_operand:VSX_EXTRACT_I 1 "register_operand")
   sh = GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) / 2;
 
   if (<MODE>mode == V16QImode)
-    emit_insn (gen_vctzlsbb_<mode> (operands[0], result));
+    {
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (operands[0], result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (operands[0], result));
+    }
   else
     {
       rtx tmp = gen_reg_rtx (SImode);
-      emit_insn (gen_vctzlsbb_<mode> (tmp, result));
-      emit_insn (gen_ashrsi3 (operands[0], tmp, GEN_INT (sh)));
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (tmp, result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (tmp, result));
+      emit_insn (gen_lshrsi3 (operands[0], tmp, GEN_INT (sh)));
     }
   DONE;
 })
 
-;; Return first position of mismatch between vectors
+;; Return first position of mismatch between vectors using natural
+;; element order for both LE and BE execution modes.
 (define_expand "first_mismatch_index_<mode>"
   [(match_operand:SI 0 "register_operand")
    (unspec: SI [(match_operand:VSX_EXTRACT_I 1 "register_operand")
   sh = GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) / 2;
 
   if (<MODE>mode == V16QImode)
-    emit_insn (gen_vctzlsbb_<mode> (operands[0], cmp_result));
+    {
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (operands[0], cmp_result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (operands[0], cmp_result));
+    }
   else
     {
       rtx tmp = gen_reg_rtx (SImode);
-      emit_insn (gen_vctzlsbb_<mode> (tmp, cmp_result));
-      emit_insn (gen_ashrsi3 (operands[0], tmp, GEN_INT (sh)));
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (tmp, cmp_result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (tmp, cmp_result));
+      emit_insn (gen_lshrsi3 (operands[0], tmp, GEN_INT (sh)));
     }
   DONE;
 })
 
 ;; Return first position of mismatch between vectors or end of string (EOS)
+;; using natural element order for both LE and BE execution modes.
 (define_expand "first_mismatch_or_eos_index_<mode>"
   [(match_operand:SI 0 "register_operand")
    (unspec: SI [(match_operand:VSX_EXTRACT_I 1 "register_operand")
   sh = GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) / 2;
 
   if (<MODE>mode == V16QImode)
-    emit_insn (gen_vctzlsbb_<mode> (operands[0], result));
+    {
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (operands[0], result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (operands[0], result));
+    }
   else
     {
       rtx tmp = gen_reg_rtx (SImode);
-      emit_insn (gen_vctzlsbb_<mode> (tmp, result));
-      emit_insn (gen_ashrsi3 (operands[0], tmp, GEN_INT (sh)));
+      if (!BYTES_BIG_ENDIAN)
+        emit_insn (gen_vctzlsbb_<mode> (tmp, result));
+      else
+        emit_insn (gen_vclzlsbb_<mode> (tmp, result));
+      emit_insn (gen_lshrsi3 (operands[0], tmp, GEN_INT (sh)));
     }
   DONE;
 })
   [(set_attr "type" "vecsimple")])
 
 ;; Vector Count Leading Zero Least-Significant Bits Byte
-(define_insn "vclzlsbb"
+(define_insn "vclzlsbb_<mode>"
   [(set (match_operand:SI 0 "register_operand" "=r")
        (unspec:SI
-        [(match_operand:V16QI 1 "altivec_register_operand" "v")]
+        [(match_operand:VSX_EXTRACT_I 1 "altivec_register_operand" "v")]
         UNSPEC_VCLZLSBB))]
   "TARGET_P9_VECTOR"
   "vclzlsbb %0,%1"
index 1bb75b2..db46ffc 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-04  Carl Love  <cel@us.ibm.com>
+
+       * gcc.target/powerpc/builtins-8-p9-runnable.c: Add additional
+       debug print statements.  Fix a few formating issues.
+
 2018-06-06  Michael Meissner  <meissner@linux.ibm.com>
 
        PR target/85657
index 9ec338d..158de5e 100644 (file)
 #include <stdio.h>
 #endif
 
+#ifdef DEBUG2
+#include <stdio.h>
+#endif
+
+
 void abort (void);
 
+#ifdef DEBUG2
+void print_signed_char (char *name, vector signed char src)
+{
+  int i;
+
+  for (i = 0; i < 8; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("\n");
+
+  for (i = 8; i < 15; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("%s[%d] = %d\n", name, 15, src[i]);
+}
+
+void print_unsigned_char (char *name, vector unsigned char src)
+{
+  int i;
+
+  for (i = 0; i < 8; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("\n");
+
+  for (i = 8; i < 15; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("%s[%d] = %d\n", name, 15, src[i]);
+}
+
+void print_signed_short_int (char *name, vector signed short int src)
+{
+  int i;
+
+  for (i = 0; i < 7; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("%s[%d] = %d\n", name, 7, src[i]);
+}
+
+void print_unsigned_short_int (char *name, vector unsigned short int src)
+{
+  int i;
+
+  for (i = 0; i < 7; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("%s[%d] = %d\n", name, 7, src[i]);
+}
+
+void print_signed_int (char *name, vector signed int src)
+{
+  int i;
+
+  for (i = 0; i < 3; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("%s[%d] = %d\n", name, 3, src[i]);
+}
+
+void print_unsigned_int (char *name, vector unsigned int src)
+{
+  int i;
+
+  for (i = 0; i < 3; i++)
+    printf("%s[%d] = %d, ", name, i, src[i]);
+
+  printf("%s[%d] = %d\n", name, 3, src[i]);
+}
+#endif
 
 int main() {
 
@@ -24,7 +100,9 @@ int main() {
   unsigned int result, expected_result;
 
 
-  /* Tests for: vec_first_match_index() */
+  /* Tests for: vec_first_match_index()
+     The element index in natural element order is returned for the
+     first match or the number of elements if there is no match.  */
   /* char */
   char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
                                    9, 10, 11, 12, 13, 14, 15, 16};
@@ -34,6 +112,12 @@ int main() {
 
   result = vec_first_match_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf(" vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first match result (%d) does not match expected result (%d)\n",
@@ -50,6 +134,12 @@ int main() {
 
   result = vec_first_match_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first match result (%d) does not match expected result (%d)\n",
@@ -66,6 +156,12 @@ int main() {
 
   result = vec_first_match_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
@@ -82,6 +178,12 @@ int main() {
 
   result = vec_first_match_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first match result (%d) does not match expected result (%d)\n",
@@ -98,6 +200,12 @@ int main() {
 
   result = vec_first_match_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first match result (%d) does not match expected result (%d)\n",
@@ -113,6 +221,12 @@ int main() {
 
   result = vec_first_match_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first match result (%d) does not match expected result (%d)\n",
@@ -128,6 +242,12 @@ int main() {
 
   result = vec_first_match_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
@@ -145,6 +265,12 @@ int main() {
 
   result = vec_first_match_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first match result (%d) does not match expected result (%d)\n",
@@ -161,6 +287,12 @@ int main() {
 
   result = vec_first_match_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first match result (%d) does not match expected result (%d)\n",
@@ -176,6 +308,12 @@ int main() {
 
   result = vec_first_match_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first match result (%d) does not match expected result (%d)\n",
@@ -191,6 +329,12 @@ int main() {
 
   result = vec_first_match_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uint first match result (%d) does not match expected result (%d)\n",
@@ -206,6 +350,12 @@ int main() {
 
   result = vec_first_match_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_match_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uint first match result (%d) does not match expected result (%d)\n",
@@ -214,7 +364,9 @@ int main() {
     abort();
 #endif
 
-  /* Tests for: vec_first_mismatch_index() */
+  /* Tests for: vec_first_mismatch_index()
+     The element index in BE order is returned for the first mismatch
+     or the number of elements if there is no match.   */
   /* char */
   char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
                                    9, 10, 11, 12, 13, 14, 15, 16};
@@ -224,6 +376,12 @@ int main() {
 
   result = vec_first_mismatch_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
@@ -240,6 +398,12 @@ int main() {
 
   result = vec_first_mismatch_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first mismatch result (%d) does not match expected result (%d)\n",
@@ -256,6 +420,12 @@ int main() {
 
   result = vec_first_mismatch_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
@@ -272,10 +442,16 @@ int main() {
 
   result = vec_first_mismatch_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
-            result, expected_result);
+           result, expected_result);
 #else
     abort();
 #endif
@@ -288,6 +464,12 @@ int main() {
 
   result = vec_first_mismatch_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch result (%d) does not match expected result (%d)\n",
@@ -304,6 +486,12 @@ int main() {
 
   result = vec_first_mismatch_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
@@ -319,6 +507,12 @@ int main() {
 
   result = vec_first_mismatch_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first mismatch result (%d) does not match expected result (%d)\n",
@@ -334,6 +528,12 @@ int main() {
 
   result = vec_first_mismatch_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
@@ -349,6 +549,12 @@ int main() {
 
   result = vec_first_mismatch_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first mismatch result (%d) does not match expected result (%d)\n",
@@ -365,6 +571,12 @@ int main() {
 
   result = vec_first_mismatch_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
@@ -380,6 +592,12 @@ int main() {
 
   result = vec_first_mismatch_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
@@ -395,6 +613,12 @@ int main() {
 
   result = vec_first_mismatch_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
@@ -410,6 +634,12 @@ int main() {
 
   result = vec_first_mismatch_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
@@ -425,7 +655,14 @@ int main() {
 
   result = vec_first_mismatch_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_mismatch_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
+
 #ifdef DEBUG
     printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
           result, expected_result);
@@ -433,7 +670,9 @@ int main() {
     abort();
 #endif
 
-  /* Tests for: vec_first_match_or_eos_index() */
+  /* Tests for: vec_first_match_or_eos_index() 
+     The element index in BE order is returned for the first match
+     or the number of elements if there is no match.  */
   /* char */
   char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
                                    9, 10, 11, 12, 13, 14, 15, 16};
@@ -443,6 +682,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first match result (%d) does not match expected result (%d)\n",
@@ -459,6 +704,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
@@ -475,12 +726,18 @@ int main() {
 
   result = vec_first_match_or_eos_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first match or EOS result (%d) does not match expected result (%d)\n",
           result, expected_result);
 #else
-     abort();
+    abort();
 #endif
 
   uchar_src1 = (vector unsigned char) {1, 2, 3, 4, 5, 6, 7, 8,
@@ -491,6 +748,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first match or EOS result (%d) does not match expected result (%d)\n",
@@ -507,6 +770,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first match or EOS  result (%d) does not match expected result (%d)\n",
@@ -523,6 +792,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -538,6 +813,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -553,6 +834,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -568,6 +855,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -583,6 +876,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -600,6 +899,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -616,10 +921,16 @@ int main() {
 
   result = vec_first_match_or_eos_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
-     printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
-           result, expected_result);
+    printf("Error: ushort int first match or EOS result (%d) does not match expected result (%d)\n",
+          result, expected_result);
 #else
     abort();
 #endif
@@ -632,6 +943,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -647,6 +964,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
@@ -662,10 +985,16 @@ int main() {
 
   result = vec_first_match_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
-     printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
-           result, expected_result);
+    printf("Error: int first match or EOS result (%d) does not match expected result (%d)\n",
+          result, expected_result);
 #else
     abort();
 #endif
@@ -677,6 +1006,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
@@ -692,6 +1027,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
@@ -707,6 +1048,12 @@ int main() {
 
   result = vec_first_match_or_eos_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_match_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uint first match or EOS result (%d) does not match expected result (%d)\n",
@@ -715,7 +1062,9 @@ int main() {
     abort();
 #endif
 
-  /* Tests for: vec_first_mismatch_or_eos_index() */
+  /* Tests for: vec_first_mismatch_or_eos_index()
+     The element index in BE order is returned for the first mismatch
+     or the number of elements if there is no match.   */
   /* char */
   char_src1 = (vector signed char) {-1, 2, 3, 4, -5, 6, 7, 8,
                                    9, 10, 11, 12, 13, 14, 15, 16};
@@ -725,6 +1074,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -741,6 +1096,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -757,6 +1118,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (char_src1, char_src2);
 
+#ifdef DEBUG2
+  print_signed_char("src1", char_src1);
+  print_signed_char("src2", char_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: char first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -773,12 +1140,18 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
           result, expected_result);
 #else
-     abort();
+    abort();
 #endif
 
   uchar_src1 = (vector unsigned char) {2, 3, 4, 5, 6, 7, 8, 9,
@@ -789,6 +1162,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -805,6 +1184,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -821,6 +1206,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uchar_src1, uchar_src2);
 
+#ifdef DEBUG2
+  print_unsigned_char("src1", uchar_src1);
+  print_unsigned_char("src2", uchar_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: uchar first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -837,6 +1228,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -852,6 +1249,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -867,6 +1270,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -882,6 +1291,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (short_src1, short_src2);
 
+#ifdef DEBUG2
+  print_signed_short_int("src1", short_src1);
+  print_signed_short_int("src2", short_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: short int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -897,6 +1312,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -912,7 +1333,13 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
 
- if (result != expected_result)
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
+  if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
           result, expected_result);
@@ -927,6 +1354,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (ushort_src1, ushort_src2);
 
+#ifdef DEBUG2
+  print_unsigned_short_int("src1", ushort_src1);
+  print_unsigned_short_int("src2", ushort_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: ushort int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -943,6 +1376,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch or EOS result (%d) does not match expected result (%d)\n",
@@ -958,6 +1397,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
@@ -973,6 +1418,12 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
@@ -988,6 +1439,11 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (int_src1, int_src2);
 
+#ifdef DEBUG2
+  print_signed_int("src1", int_src1);
+  print_signed_int("src2", int_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
   if (result != expected_result)
 #ifdef DEBUG
     printf("Error: int first mismatch result (%d) does not match expected result (%d)\n",
@@ -1003,9 +1459,14 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
   if (result != expected_result)
 #ifdef DEBUG
-    printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
+    printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
           result, expected_result);
 #else
     abort();
@@ -1018,9 +1479,15 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
-    printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
+    printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
           result, expected_result);
 #else
     abort();
@@ -1033,9 +1500,15 @@ int main() {
 
   result = vec_first_mismatch_or_eos_index (uint_src1, uint_src2);
 
+#ifdef DEBUG2
+  print_unsigned_int("src1", uint_src1);
+  print_unsigned_int("src2", uint_src2);
+  printf("vec_first_mismatch_or_eos_index = %d\n\n", result);
+#endif
+
   if (result != expected_result)
 #ifdef DEBUG
-    printf("Error: uint first mismatch result (%d) does not match expected result (%d)\n",
+    printf("Error: uint first mismatch or eos index result (%d) does not match expected result (%d)\n",
           result, expected_result);
 #else
     abort();