OSDN Git Service

PR driver/40144
[pf3gnuchains/gcc-fork.git] / gcc / tree-loop-linear.c
index f58bd11..cc2440d 100644 (file)
@@ -1,5 +1,6 @@
 /* Linear Loop transforms
-   Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
+   Free Software Foundation, Inc.
    Contributed by Daniel Berlin <dberlin@dberlin.org>.
 
 This file is part of GCC.
@@ -89,13 +90,13 @@ along with GCC; see the file COPYING3.  If not see
 */
 
 static void
-gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
-                         VEC (data_reference_p, heap) *datarefs,
-                         struct loop *loop,
-                         struct loop *first_loop,
-                         unsigned int *dependence_steps, 
-                         unsigned int *nb_deps_not_carried_by_loop, 
-                         double_int *access_strides)
+gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations ATTRIBUTE_UNUSED,
+                         VEC (data_reference_p, heap) *datarefs ATTRIBUTE_UNUSED,
+                         struct loop *loop ATTRIBUTE_UNUSED,
+                         struct loop *first_loop ATTRIBUTE_UNUSED,
+                         unsigned int *dependence_steps ATTRIBUTE_UNUSED
+                         unsigned int *nb_deps_not_carried_by_loop ATTRIBUTE_UNUSED
+                         double_int *access_strides ATTRIBUTE_UNUSED)
 {
   unsigned int i, j;
   struct data_dependence_relation *ddr;
@@ -135,7 +136,7 @@ gather_interchange_stats (VEC (ddr_p, heap) *dependence_relations,
     {
       unsigned int it;
       tree ref = DR_REF (dr);
-      tree stmt = DR_STMT (dr);
+      gimple stmt = DR_STMT (dr);
       struct loop *stmt_loop = loop_containing_stmt (stmt);
       struct loop *inner_loop = first_loop->inner;
 
@@ -272,7 +273,7 @@ try_interchange_loops (lambda_trans_matrix trans,
 /* Return the number of nested loops in LOOP_NEST, or 0 if the loops
    are not perfectly nested.  */
 
-static unsigned int
+unsigned int
 perfect_loop_nest_depth (struct loop *loop_nest)
 {
   struct loop *temp;
@@ -319,9 +320,9 @@ linear_transform_loops (void)
   VEC(tree,heap) *oldivs = NULL;
   VEC(tree,heap) *invariants = NULL;
   VEC(tree,heap) *lambda_parameters = NULL;
-  VEC(tree,heap) *remove_ivs = VEC_alloc (tree, heap, 3);
+  VEC(gimple,heap) *remove_ivs = VEC_alloc (gimple, heap, 3);
   struct loop *loop_nest;
-  tree oldiv_stmt;
+  gimple oldiv_stmt;
   unsigned i;
 
   FOR_EACH_LOOP (li, loop_nest, 0)
@@ -333,12 +334,18 @@ linear_transform_loops (void)
       lambda_loopnest before, after;
       lambda_trans_matrix trans;
       struct obstack lambda_obstack;
-      gcc_obstack_init (&lambda_obstack);
+      struct loop *loop;
+      VEC(loop_p,heap) *nest;
 
       depth = perfect_loop_nest_depth (loop_nest);
       if (depth == 0)
        continue;
 
+      nest = VEC_alloc (loop_p, heap, 3);
+      for (loop = loop_nest; loop; loop = loop->inner)
+       VEC_safe_push (loop_p, heap, nest, loop);
+
+      gcc_obstack_init (&lambda_obstack);
       VEC_truncate (tree, oldivs, 0);
       VEC_truncate (tree, invariants, 0);
       VEC_truncate (tree, lambda_parameters, 0);
@@ -347,12 +354,11 @@ linear_transform_loops (void)
       dependence_relations = VEC_alloc (ddr_p, heap, 10 * 10);
       if (!compute_data_dependences_for_loop (loop_nest, true, &datarefs,
                                              &dependence_relations))
-       continue;
+       goto free_and_continue;
       
       lambda_collect_parameters (datarefs, &lambda_parameters);
-      if (!lambda_compute_access_matrices (datarefs, lambda_parameters,
-                                          loop_nest->num))
-       continue;
+      if (!lambda_compute_access_matrices (datarefs, lambda_parameters, nest))
+       goto free_and_continue;
 
       if (dump_file && (dump_flags & TDF_DETAILS))
        dump_ddrs (dump_file, dependence_relations);
@@ -410,14 +416,15 @@ linear_transform_loops (void)
       obstack_free (&lambda_obstack, NULL);
       free_dependence_relations (dependence_relations);
       free_data_refs (datarefs);
+      VEC_free (loop_p, heap, nest);
     }
 
-  for (i = 0; VEC_iterate (tree, remove_ivs, i, oldiv_stmt); i++)
+  for (i = 0; VEC_iterate (gimple, remove_ivs, i, oldiv_stmt); i++)
     remove_iv (oldiv_stmt);
 
   VEC_free (tree, heap, oldivs);
   VEC_free (tree, heap, invariants);
-  VEC_free (tree, heap, remove_ivs);
+  VEC_free (gimple, heap, remove_ivs);
   scev_reset ();
 
   if (modified)