This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR92260


The following fixes the PR.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-10-29  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/92260
	* tree-vect-slp.c (vect_get_constant_vectors): Special-case
	lane-reducing ops.

	* gcc.dg/pr92260.c: New testcase.

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	(revision 277566)
+++ gcc/tree-vect-slp.c	(working copy)
@@ -3395,10 +3399,19 @@ vect_get_constant_vectors (slp_tree op_n
   else
     vector_type = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op));
 
-  unsigned int number_of_vectors
-    = vect_get_num_vectors (SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node)
-			    * TYPE_VECTOR_SUBPARTS (stmt_vectype),
-			    vector_type);
+  /* ???  For lane-reducing ops we should also have the required number
+     of vector stmts initialized rather than second-guessing here.  */
+  unsigned int number_of_vectors;
+  if (is_gimple_assign (stmt_vinfo->stmt)
+      && (gimple_assign_rhs_code (stmt_vinfo->stmt) == SAD_EXPR
+	  || gimple_assign_rhs_code (stmt_vinfo->stmt) == DOT_PROD_EXPR
+	  || gimple_assign_rhs_code (stmt_vinfo->stmt) == WIDEN_SUM_EXPR))
+    number_of_vectors = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
+  else
+    number_of_vectors
+      = vect_get_num_vectors (SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node)
+			      * TYPE_VECTOR_SUBPARTS (stmt_vectype),
+			      vector_type);
   vec_oprnds->create (number_of_vectors);
   auto_vec<tree> voprnds (number_of_vectors);
 
Index: gcc/testsuite/gcc.dg/pr92260.c
===================================================================
--- gcc/testsuite/gcc.dg/pr92260.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr92260.c	(working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+extern int abs(int);
+int e(const unsigned char *g, long h, unsigned char m)
+{
+  int i = 0;
+  for (int j = 0; j < h; j++)
+    {
+      for (int k = 0; k < 4; k++)
+	i += abs(g[k] - m);
+      g += h;
+    }
+  return i;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]