re PR tree-optimization/92205 (ICE in vect_get_vec_def_for_stmt_copy, at tree-vect...
authorRichard Biener <rguenther@suse.de>
Thu, 24 Oct 2019 12:11:27 +0000 (12:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 24 Oct 2019 12:11:27 +0000 (12:11 +0000)
2019-10-24  Richard Biener  <rguenther@suse.de>

PR tree-optimization/92205
* tree-vect-loop.c (vectorizable_reduction): Restrict
search for alternate vectype_in to lane-reducing patterns
we support.

* gcc.dg/vect/pr92205.c: New testcase.

From-SVN: r277375

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr92205.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 48733302092c135ff890f753ecb68555b7d57ded..d09b72d2b163a2bda188352640902193ffd3930f 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-24  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92205
+       * tree-vect-loop.c (vectorizable_reduction): Restrict
+       search for alternate vectype_in to lane-reducing patterns
+       we support.
+
 2019-10-24  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92203
index 5a1cd91461c7915b509c114b0e3241af6210af40..2742e10bb6f32d09e2b94217b8ec454d78432070 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-24  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/92205
+       * gcc.dg/vect/pr92205.c: New testcase.
+
 2019-10-24  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92203
diff --git a/gcc/testsuite/gcc.dg/vect/pr92205.c b/gcc/testsuite/gcc.dg/vect/pr92205.c
new file mode 100644 (file)
index 0000000..ea06660
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
+int b(int n, unsigned char *a)
+{
+  int d = 0;
+  a = __builtin_assume_aligned (a, __BIGGEST_ALIGNMENT__);
+  for (int c = 0; c < n; ++c)
+    d |= a[c];
+  return d;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_unpack && { ! vect_no_bitwise } } } } } */
index b66f211c350dee8153c0e29044baef8b35aac2b6..9c5ce47249c2b6da9d6f83baa022b97dbc2542d2 100644 (file)
@@ -5697,6 +5697,8 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
 
   gassign *stmt = as_a <gassign *> (stmt_info->stmt);
   enum tree_code code = gimple_assign_rhs_code (stmt);
+  bool lane_reduc_code_p
+    = (code == DOT_PROD_EXPR || code == WIDEN_SUM_EXPR || code == SAD_EXPR);
   int op_type = TREE_CODE_LENGTH (code);
 
   scalar_dest = gimple_assign_lhs (stmt);
@@ -5749,8 +5751,10 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
        return false;
 
       /* To properly compute ncopies we are interested in the widest
-        input type in case we're looking at a widening accumulation.  */
-      if (tem
+        non-reduction input type in case we're looking at a widening
+        accumulation that we later handle in vect_transform_reduction.  */
+      if (lane_reduc_code_p
+         && tem
          && (!vectype_in
              || (GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE (vectype_in)))
                  < GET_MODE_SIZE (SCALAR_TYPE_MODE (TREE_TYPE (tem))))))
@@ -6233,8 +6237,6 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
       && vect_stmt_to_vectorize (use_stmt_info) == stmt_info)
     single_defuse_cycle = true;
 
-  bool lane_reduc_code_p
-    = (code == DOT_PROD_EXPR || code == WIDEN_SUM_EXPR || code == SAD_EXPR);
   if (single_defuse_cycle || lane_reduc_code_p)
     {
       gcc_assert (code != COND_EXPR);