]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/58453 (Revision 202431 results in miscompare for CPU2006...
authorRichard Biener <rguenther@suse.de>
Fri, 20 Sep 2013 12:21:08 +0000 (12:21 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Sep 2013 12:21:08 +0000 (12:21 +0000)
2013-09-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/58453
* tree-loop-distribution.c (distribute_loop): Apply the cost
model for -ftree-loop-distribute-patterns, too.

* gcc.dg/tree-ssa/ldist-23.c: New testcase.

From-SVN: r202775

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ldist-23.c [new file with mode: 0644]
gcc/tree-loop-distribution.c

index 14c30162e3fd71182efccffe00bbc4bbdd7fcaf7..e4e4a69a87121bb368743e76da95fafa4d9b70d2 100644 (file)
@@ -1,3 +1,9 @@
+2013-09-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58453
+       * tree-loop-distribution.c (distribute_loop): Apply the cost
+       model for -ftree-loop-distribute-patterns, too.
+
 2013-09-20  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/58473
index 203fd13ddb04ac2e4e214306e2d879212e79f26c..8d287f1665c781bfeff017441d275a0489f53b41 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58453
+       * gcc.dg/tree-ssa/ldist-23.c: New testcase.
+
 2013-09-20  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/58099
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-23.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-23.c
new file mode 100644 (file)
index 0000000..22b82d9
--- /dev/null
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fdump-tree-ldist-details" } */
+
+extern void abort (void);
+
+int a[128], b[128], c[128], d[128];
+
+void __attribute__((noinline,noclone))
+foo (void)
+{
+  int i;
+  for (i = 0; i < 128; ++i)
+    {
+      a[i] = a[i] + 1;
+      b[i] = d[i];
+      c[i] = a[i] / d[i];
+    }
+}
+int main()
+{
+  int i;
+  for (i = 0; i < 128; ++i)
+    a[i] = i;
+  for (i = 0; i < 128; ++i)
+    d[i] = 1;
+  foo ();
+  if (c[0] != 1)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "split to 2 loops" "ldist" } } */
+/* { dg-final { scan-tree-dump "generated memcpy" "ldist" } } */
+/* { dg-final { cleanup-tree-dump "ldist" } } */
index 7482d8c68bc48973f06882d237b84a93e73b9e4c..51b6ef03b4e7d831266e75e606723c21f4e084ee 100644 (file)
@@ -1514,18 +1514,51 @@ distribute_loop (struct loop *loop, vec<gimple> stmts,
       any_builtin |= partition_builtin_p (partition);
     }
 
+  /* If we did not detect any builtin but are not asked to apply
+     regular loop distribution simply bail out.  */
+  if (!flag_tree_loop_distribution
+      && !any_builtin)
+    {
+      nbp = 0;
+      goto ldist_done;
+    }
+
+  /* Apply our simple cost model - fuse partitions with similar
+     memory accesses.  */
+  partition_t into;
+  for (i = 0; partitions.iterate (i, &into); ++i)
+    {
+      if (partition_builtin_p (into))
+       continue;
+      for (int j = i + 1;
+          partitions.iterate (j, &partition); ++j)
+       {
+         if (!partition_builtin_p (partition)
+             && similar_memory_accesses (rdg, into, partition))
+           {
+             if (dump_file && (dump_flags & TDF_DETAILS))
+               {
+                 fprintf (dump_file, "fusing partitions\n");
+                 dump_bitmap (dump_file, into->stmts);
+                 dump_bitmap (dump_file, partition->stmts);
+                 fprintf (dump_file, "because they have similar "
+                          "memory accesses\n");
+               }
+             bitmap_ior_into (into->stmts, partition->stmts);
+             if (partition->kind == PKIND_REDUCTION)
+               into->kind = PKIND_REDUCTION;
+             partitions.ordered_remove (j);
+             partition_free (partition);
+             j--;
+           }
+       }
+    }
+
   /* If we are only distributing patterns fuse all partitions that
-     were not properly classified as builtins.  Else fuse partitions
-     with similar memory accesses.  */
+     were not properly classified as builtins.  */
   if (!flag_tree_loop_distribution)
     {
       partition_t into;
-      /* If we did not detect any builtin simply bail out.  */
-      if (!any_builtin)
-       {
-         nbp = 0;
-         goto ldist_done;
-       }
       /* Only fuse adjacent non-builtin partitions, see PR53616.
          ???  Use dependence information to improve partition ordering.  */
       i = 0;
@@ -1549,38 +1582,6 @@ distribute_loop (struct loop *loop, vec<gimple> stmts,
        }
       while ((unsigned) i < partitions.length ());
     }
-  else
-    {
-      partition_t into;
-      int j;
-      for (i = 0; partitions.iterate (i, &into); ++i)
-       {
-         if (partition_builtin_p (into))
-           continue;
-         for (j = i + 1;
-              partitions.iterate (j, &partition); ++j)
-           {
-             if (!partition_builtin_p (partition)
-                 && similar_memory_accesses (rdg, into, partition))
-               {
-                 if (dump_file && (dump_flags & TDF_DETAILS))
-                   {
-                     fprintf (dump_file, "fusing partitions\n");
-                     dump_bitmap (dump_file, into->stmts);
-                     dump_bitmap (dump_file, partition->stmts);
-                     fprintf (dump_file, "because they have similar "
-                              "memory accesses\n");
-                   }
-                 bitmap_ior_into (into->stmts, partition->stmts);
-                 if (partition->kind == PKIND_REDUCTION)
-                   into->kind = PKIND_REDUCTION;
-                 partitions.ordered_remove (j);
-                 partition_free (partition);
-                 j--;
-               }
-           }
-       }
-    }
 
   /* Fuse all reduction partitions into the last.  */
   if (partitions.length () > 1)