re PR middle-end/52835 (-O3 wrongly optimizes loop __builtin_memcpy away)
authorJakub Jelinek <jakub@redhat.com>
Tue, 3 Apr 2012 08:49:14 +0000 (10:49 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 3 Apr 2012 08:49:14 +0000 (10:49 +0200)
PR tree-optimization/52835
* tree-data-ref.c (build_rdg): Return NULL if
compute_data_dependences_for_loop failed.

* gfortran.dg/pr52835.f90: New test.

From-SVN: r186101

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr52835.f90 [new file with mode: 0644]
gcc/tree-data-ref.c

index 96bcc5c..72e14f4 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/52835
+       * tree-data-ref.c (build_rdg): Return NULL if
+       compute_data_dependences_for_loop failed.
+
 2012-04-03  Eric Botcazou  <ebotcazou@adacore.com>
 
        * varasm.c (initializer_constant_valid_for_bitfield_p): Return true
index 5a5ee57..7fe8a18 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/52835
+       * gfortran.dg/pr52835.f90: New test.
+
 2012-04-03  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/aggr5.ads: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr52835.f90 b/gcc/testsuite/gfortran.dg/pr52835.f90
new file mode 100644 (file)
index 0000000..a72951a
--- /dev/null
@@ -0,0 +1,16 @@
+! PR tree-optimization/52835
+! { dg-do compile }
+! { dg-options "-O3 -fdump-tree-optimized" }
+
+subroutine foo (x, y, z, n)
+  integer :: n, i
+  real :: x(n), y(n), z(n)
+  do i = 1, n
+    z(i) = 0.0
+    y(i) = 0.0
+    call bar (y(i), z(i), x(i))
+  end do
+end subroutine
+
+! { dg-final { scan-tree-dump "bar " "optimized" } }
+! { dg-final { cleanup-tree-dump "optimized" } }
index 5dcafd3..6fb0d23 100644 (file)
@@ -5109,20 +5109,19 @@ build_rdg (struct loop *loop,
           VEC (data_reference_p, heap) **datarefs)
 {
   struct graph *rdg = NULL;
-  VEC (gimple, heap) *stmts = VEC_alloc (gimple, heap, 10);
 
-  compute_data_dependences_for_loop (loop, false, loop_nest, datarefs,
-                                    dependence_relations);
-
-  if (known_dependences_p (*dependence_relations))
+  if (compute_data_dependences_for_loop (loop, false, loop_nest, datarefs,
+                                        dependence_relations)
+      && known_dependences_p (*dependence_relations))
     {
+      VEC (gimple, heap) *stmts = VEC_alloc (gimple, heap, 10);
       stmts_from_loop (loop, &stmts);
       rdg = build_empty_rdg (VEC_length (gimple, stmts));
       create_rdg_vertices (rdg, stmts);
       create_rdg_edges (rdg, *dependence_relations);
+      VEC_free (gimple, heap, stmts);
     }
 
-  VEC_free (gimple, heap, stmts);
   return rdg;
 }