pr94833, fix vec_first_match_index for nulls
authorCarl Love <cel@us.ibm.com>
Wed, 29 Apr 2020 15:23:11 +0000 (10:23 -0500)
committerCarl Love <cel@us.ibm.com>
Mon, 18 May 2020 17:14:40 +0000 (12:14 -0500)
gcc/ChangeLog

2020-04-30  Carl Love  <cel@us.ibm.com>

PR target/94833
* config/rs6000/vsx.md (define_expand): Fix instruction generation for
first_match_index_<mode>.
* testsuite/gcc.target/powerpc/builtins-8-p9-runnable.c (main): Add
additional test cases with zero vector elements.

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

index 4082217..51b5b6c 100644 (file)
@@ -1,3 +1,11 @@
+2020-05-18  Carl Love  <cel@us.ibm.com>
+
+       PR target/94833
+       * config/rs6000/vsx.md (define_expand): Fix instruction generation for
+       first_match_index_<mode>.
+       * testsuite/gcc.target/powerpc/builtins-8-p9-runnable.c (main): Add
+       additional test cases with zero vector elements.
+
 2020-05-18  Uroš Bizjak  <ubizjak@gmail.com>
 
        PR target/95169
index 62b4f61..2a28215 100644 (file)
   rtx cmp_result = gen_reg_rtx (<MODE>mode);
   rtx not_result = gen_reg_rtx (<MODE>mode);
 
-  emit_insn (gen_vcmpnez<VSX_EXTRACT_WIDTH> (cmp_result, operands[1],
-                                            operands[2]));
+  emit_insn (gen_vcmpne<VSX_EXTRACT_WIDTH> (cmp_result, operands[1],
+                                           operands[2]));
   emit_insn (gen_one_cmpl<mode>2 (not_result, cmp_result));
 
   sh = GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) / 2;
index b2f7dc8..19457ee 100644 (file)
@@ -103,6 +103,31 @@ int main() {
      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) { 0x40, 0, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40 };
+                                   
+  char_src2 = (vector signed char) {0, 0, 0, 0, 0, 0, 0, 0,
+                                   0, 0, 0, 0, 0, 0, 0, 0};
+  expected_result = 1;
+
+  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",
+          result, expected_result);
+#else
+    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, 20, -5, 6, 7, 8,
@@ -367,6 +392,50 @@ int main() {
      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, 0, 4, -5, 6, 7, 8,
+                                   9, 10, 11, 12, 13, 14, 15, 16};
+  char_src2 = (vector signed char) {1, 2, 0, 20, -5, 6, 7, 8,
+                                   9, 10, 11, 12, 13, 14, 15, 16};
+  expected_result = 3;
+
+  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",
+          result, expected_result);
+#else
+    abort();
+#endif
+
+  char_src1 = (vector signed char) {0, 2, 3, 4, -5, 6, 7, 8,
+                                   9, 10, 11, 12, 13, 14, 15, 16};
+  char_src2 = (vector signed char) {0, 2, 3, 20, -5, 6, 7, 8,
+                                   9, 10, 11, 12, 13, 14, 15, 16};
+  expected_result = 3;
+
+  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",
+          result, expected_result);
+#else
+    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, 20, -5, 6, 7, 8,
@@ -673,6 +742,33 @@ int main() {
      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) { 0x40, 0, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40 };
+                                   
+  char_src2 = (vector signed char) { 0x41, 0, 0x43, 0x44,
+                                    0x45, 0x46, 0x47, 0x40,
+                                    0x40, 0x40, 0x40, 0x40,
+                                    0x40, 0x40, 0x40, 0x40 };
+  expected_result = 1;
+
+  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",
+          result, expected_result);
+#else
+    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, 20, -5, 6, 7, 8,
@@ -1065,6 +1161,28 @@ int main() {
      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, 0, 4, -5, 6, 7, 8,
+                                   9, 10, 11, 12, 13, 14, 15, 16};
+  char_src2 = (vector signed char) {1, 2, 0, 20, -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);
+
+#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",
+          result, expected_result);
+#else
+    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, 20, -5, 6, 7, 8,