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 PR59354


The following fixes PR59354 by treating loads from a group larger
than the SLP size as having gaps if the loop is unrolled.  This
usually means we combine parts of the group of different unroll
interations which effectively introduces a gap.

Of course in the end this check should be postponed and we should
split groups according to uses in SLP instances after SLP discovery...
(but not for GCC 5)

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2015-01-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59354
	* tree-vect-slp.c (vect_build_slp_tree_1): Treat loads from
	groups larger than the slp group size as having gaps.

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

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c	(revision 219581)
+++ gcc/tree-vect-slp.c	(working copy)
@@ -729,8 +729,11 @@ vect_build_slp_tree_1 (loop_vec_info loo
 		 ???  We should enhance this to only disallow gaps
 		 inside vectors.  */
               if ((unrolling_factor > 1
-		   && GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt
-		   && GROUP_GAP (vinfo_for_stmt (stmt)) != 0)
+		   && ((GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt
+			&& GROUP_GAP (vinfo_for_stmt (stmt)) != 0)
+		       /* If the group is split up then GROUP_GAP
+			  isn't correct here, nor is GROUP_FIRST_ELEMENT.  */
+		       || GROUP_SIZE (vinfo_for_stmt (stmt)) > group_size))
 		  || (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) != stmt
 		      && GROUP_GAP (vinfo_for_stmt (stmt)) != 1))
                 {
Index: gcc/testsuite/gcc.dg/vect/pr59354.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr59354.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/pr59354.c	(working copy)
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+void abort (void);
+
+unsigned int a[256];
+unsigned char b[256];
+
+int main()
+{
+  int i, z, x, y;
+
+  check_vect ();
+
+  for(i = 0; i < 256; i++)
+    {
+      a[i] = i % 5;
+      __asm__ volatile ("");
+    }
+
+  for (z = 0; z < 16; z++)
+    for (y = 0; y < 4; y++)
+      for (x = 0; x < 4; x++)
+	b[y*64 + z*4 + x] = a[z*16 + y*4 + x];
+
+  if (b[4] != 1)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "vect" "vectorized 1 loop" { target { vect_pack_trunc } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */


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