re PR tree-optimization/56826 (Run-fail after r197189.)
authorRichard Biener <rguenther@suse.de>
Thu, 4 Apr 2013 15:06:44 +0000 (15:06 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 4 Apr 2013 15:06:44 +0000 (15:06 +0000)
2013-04-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/56826
* tree-vect-slp.c (vect_build_slp_tree): Compute ncopies
more accurately.

* gcc.dg/vect/pr56826.c: New testcase.
* gcc.dg/vect/O3-pr36098.c: Adjust.

From-SVN: r197486

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/O3-pr36098.c
gcc/testsuite/gcc.dg/vect/pr56826.c [new file with mode: 0644]
gcc/tree-vect-slp.c

index 09f5ff5478ae493db898dc62485eed3071eee09c..970c0d97fd1c9c5e54327455402c20a40599f920 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56826
+       * tree-vect-slp.c (vect_build_slp_tree): Compute ncopies
+       more accurately.
+
 2013-04-04  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/56213
index 06f6c981bf96fe3d4e672d034f50212484ce0cb6..a65b101de03be8310bf47e5ef023b51b60221d34 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56826
+       * gcc.dg/vect/pr56826.c: New testcase.
+       * gcc.dg/vect/O3-pr36098.c: Adjust.
+
 2013-04-04  Tejas Belagod  <tejas.belagod@arm.com>
 
        * gcc.target/aarch64/inc/asm-adder-clobber-lr.c: Remove duplication.
index 9e87b2372db8e0b58f0351b5aaaded401965c797..b0b8e3c94665e1f20d4653beb6e7f7a30e313c12 100644 (file)
@@ -17,5 +17,5 @@ void foo (int ncons, t_sortblock *sb, int *iatom)
      iatom[m]=sb[i].iatom[m];
 }
 
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr56826.c b/gcc/testsuite/gcc.dg/vect/pr56826.c
new file mode 100644 (file)
index 0000000..7a5c5ff
--- /dev/null
@@ -0,0 +1,41 @@
+extern void abort (void);\r
+\r
+typedef struct {\r
+    int a[3];\r
+    int num;\r
+} t1;\r
+t1 B[100];\r
+int A[300];\r
+\r
+void __attribute__((noinline,noclone))\r
+bar (int *A, t1 *B, int n)\r
+{\r
+  int i;\r
+  int *a = A;\r
+  for (i=0; i<n; i++, a+=3)\r
+    {\r
+      a[0] = B[i].a[0];\r
+      a[1] = B[i].a[1];\r
+      a[2] = B[i].a[2];\r
+    }\r
+}\r
+\r
+int main()\r
+{\r
+  int i;\r
+  for (i=0; i<100; i++) \r
+    {\r
+      B[i].num = i;\r
+      B[i].a[0] = i * 3;\r
+      B[i].a[1] = i * 3 + 1;\r
+      B[i].a[2] = i * 3 + 2;\r
+      __asm__ volatile ("");\r
+    }\r
+  bar (&A[0], &B[0], 100);\r
+  for (i=0; i<300; i++)\r
+    if (A[i] != i)\r
+      abort ();\r
+  return 0;\r
+} \r
+\r
+/* { dg-final { cleanup-tree-dump "vect" } } */\r
index a9cf6920cf68656d9867c815a9e1bfe3030368e7..4a5317dc3ce82340946344de8e34a38da9f20943 100644 (file)
@@ -470,7 +470,6 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
   tree lhs;
   bool stop_recursion = false, need_same_oprnds = false;
   tree vectype, scalar_type, first_op1 = NULL_TREE;
-  unsigned int ncopies;
   optab optab;
   int icode;
   enum machine_mode optab_op2_mode;
@@ -577,8 +576,6 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
             vectorization_factor = *max_nunits;
         }
 
-      ncopies = vectorization_factor / TYPE_VECTOR_SUBPARTS (vectype);
-
       if (is_gimple_call (stmt))
        {
          rhs_code = CALL_EXPR;
@@ -741,12 +738,15 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
          else
            {
              /* Load.  */
+             unsigned unrolling_factor
+               = least_common_multiple
+                   (*max_nunits, group_size) / group_size;
               /* FORNOW: Check that there is no gap between the loads
                 and no gap between the groups when we need to load
                 multiple groups at once.
                 ???  We should enhance this to only disallow gaps
                 inside vectors.  */
-              if ((ncopies > 1
+              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
@@ -767,6 +767,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
 
               /* Check that the size of interleaved loads group is not
                  greater than the SLP group size.  */
+             unsigned ncopies
+               = vectorization_factor / TYPE_VECTOR_SUBPARTS (vectype);
               if (loop_vinfo
                  && GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) == stmt
                   && ((GROUP_SIZE (vinfo_for_stmt (stmt))