]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/58223 (wrong code at -O3 on x86_64-linux-gnu)
authorRichard Biener <rguenther@suse.de>
Fri, 30 Aug 2013 07:48:53 +0000 (07:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 30 Aug 2013 07:48:53 +0000 (07:48 +0000)
2013-08-30  Richard Biener  <rguenther@suse.de>

PR tree-optimization/58223
* tree-loop-distribution.c (has_anti_dependence): Rename to ...
(has_anti_or_output_dependence): ... this and adjust to also
look for output dependences.
(mark_nodes_having_upstream_mem_writes): Adjust.
(rdg_flag_uses): Likewise.

* gcc.dg/torture/pr58223.c: New testcase.
* gcc.dg/tree-ssa/ldist-16.c: Flip expected behavior.

From-SVN: r202096

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

index 3c46e54135efc8e3aff5c0fad80a73675c34042e..7a8782b0f13b292e2e392ac1e0a284ff87efafc0 100644 (file)
@@ -1,3 +1,12 @@
+2013-08-30  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58223
+       * tree-loop-distribution.c (has_anti_dependence): Rename to ...
+       (has_anti_or_output_dependence): ... this and adjust to also
+       look for output dependences.
+       (mark_nodes_having_upstream_mem_writes): Adjust.
+       (rdg_flag_uses): Likewise.
+
 2013-08-30  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/58010
index 8d93f2ef9936226eb5440317117c534055f39aa1..e6fa611cf502209980173e269e303c94c3f36bba 100644 (file)
@@ -1,3 +1,9 @@
+2013-08-30  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/58223
+       * gcc.dg/torture/pr58223.c: New testcase.
+       * gcc.dg/tree-ssa/ldist-16.c: Flip expected behavior.
+
 2013-08-30  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/58010
diff --git a/gcc/testsuite/gcc.dg/torture/pr58223.c b/gcc/testsuite/gcc.dg/torture/pr58223.c
new file mode 100644 (file)
index 0000000..978084a
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+extern void abort (void);
+int a[2], b;
+
+int main ()
+{
+  for (b = 0; b < 2; b++)
+    {
+      a[0] = 1;
+      a[b] = 0;
+    }
+  if (a[0] != 1)
+    abort ();
+  return 0;
+}
index a26999e890593cb1616ad7316e6b27a0d0a667b2..53a9fa4f9e3b1e54f795cff4dae271bfe79c80ad 100644 (file)
@@ -14,8 +14,8 @@ void foo (int n)
     }
 }
 
-/* We should apply loop distribution and generate a memset (0).  */
+/* We should not apply loop distribution and not generate a memset (0).  */
 
-/* { dg-final { scan-tree-dump "distributed: split to 2" "ldist" } } */
-/* { dg-final { scan-tree-dump-times "generated memset zero" 1 "ldist" } } */
+/* { dg-final { scan-tree-dump "Loop 1 is the same" "ldist" } } */
+/* { dg-final { scan-tree-dump-times "generated memset zero" 0 "ldist" } } */
 /* { dg-final { cleanup-tree-dump "ldist" } } */
index 2317edcc7a391688d410d923a055954f209c6e1d..95c4d5f753a0c563f76c97e1573fa8f592c9fc52 100644 (file)
@@ -542,17 +542,19 @@ already_processed_vertex_p (bitmap processed, int v)
          || !bitmap_bit_p (remaining_stmts, v));
 }
 
-/* Returns NULL when there is no anti-dependence among the successors
-   of vertex V, otherwise returns the edge with the anti-dep.  */
+/* Returns NULL when there is no anti-dependence or output-dependence
+   among the successors of vertex V, otherwise returns the edge with the
+   dependency.  */
 
 static struct graph_edge *
-has_anti_dependence (struct vertex *v)
+has_anti_or_output_dependence (struct vertex *v)
 {
   struct graph_edge *e;
 
   if (v->succ)
     for (e = v->succ; e; e = e->succ_next)
-      if (RDGE_TYPE (e) == anti_dd)
+      if (RDGE_TYPE (e) == anti_dd
+         || RDGE_TYPE (e) == output_dd)
        return e;
 
   return NULL;
@@ -604,11 +606,10 @@ mark_nodes_having_upstream_mem_writes (struct graph *rdg)
                || predecessor_has_mem_write (rdg, &(rdg->vertices[x]))
                /* In anti dependences the read should occur before
                   the write, this is why both the read and the write
-                  should be placed in the same partition.  */
-               || has_anti_dependence (&(rdg->vertices[x])))
-             {
-               bitmap_set_bit (upstream_mem_writes, x);
-             }
+                  should be placed in the same partition.  In output
+                  dependences the writes order need to be preserved.  */
+               || has_anti_or_output_dependence (&(rdg->vertices[x])))
+             bitmap_set_bit (upstream_mem_writes, x);
          }
 
        nodes.release ();
@@ -637,7 +638,7 @@ rdg_flag_uses (struct graph *rdg, int u, partition_t partition, bitmap loops,
   use_operand_p use_p;
   struct vertex *x = &(rdg->vertices[u]);
   gimple stmt = RDGV_STMT (x);
-  struct graph_edge *anti_dep = has_anti_dependence (x);
+  struct graph_edge *anti_dep = has_anti_or_output_dependence (x);
 
   /* Keep in the same partition the destination of an antidependence,
      because this is a store to the exact same location.  Putting this
This page took 0.122676 seconds and 5 git commands to generate.