OSDN Git Service

fortran/
[pf3gnuchains/gcc-fork.git] / gcc / tree-loop-linear.c
index bf353e5..2840e9b 100644 (file)
@@ -178,6 +178,9 @@ try_interchange_loops (lambda_trans_matrix trans,
   unsigned int nb_deps_not_carried_by_i, nb_deps_not_carried_by_j;
   struct data_dependence_relation *ddr;
 
+  if (VEC_length (ddr_p, dependence_relations) == 0)
+    return trans;
+
   /* When there is an unknown relation in the dependence_relations, we
      know that it is no worth looking at this loop nest: give up.  */
   ddr = VEC_index (ddr_p, dependence_relations, 0);
@@ -238,6 +241,7 @@ try_interchange_loops (lambda_trans_matrix trans,
 void
 linear_transform_loops (struct loops *loops)
 {
+  bool modified = false;
   unsigned int i;
   VEC(tree,heap) *oldivs = NULL;
   VEC(tree,heap) *invariants = NULL;
@@ -252,7 +256,6 @@ linear_transform_loops (struct loops *loops)
       lambda_loopnest before, after;
       lambda_trans_matrix trans;
       bool problem = false;
-      bool need_perfect_nest = false;
       /* If it's not a loop nest, we don't want it.
          We also don't handle sibling loops properly, 
          which are loops of the following form:
@@ -262,12 +265,12 @@ linear_transform_loops (struct loops *loops)
                {
                ...
                }
-           for (j = 0; j < 50; j++)
+             for (j = 0; j < 50; j++)
                {
                 ...
                }
            } */
-      if (!loop_nest || !loop_nest->inner)
+      if (!loop_nest || !loop_nest->inner || !loop_nest->single_exit)
        continue;
       VEC_truncate (tree, oldivs, 0);
       VEC_truncate (tree, invariants, 0);
@@ -305,7 +308,7 @@ linear_transform_loops (struct loops *loops)
        {
          if (dump_file)
           fprintf (dump_file, "Won't transform loop. Optimal transform is the identity transform\n");
-         continue;
+         goto free_and_continue;
        }
 
       /* Check whether the transformation is legal.  */
@@ -313,19 +316,15 @@ linear_transform_loops (struct loops *loops)
        {
          if (dump_file)
            fprintf (dump_file, "Can't transform loop, transform is illegal:\n");
-         continue;
+         goto free_and_continue;
        }
 
-      if (!perfect_nest_p (loop_nest))
-       need_perfect_nest = true;
+      before = gcc_loopnest_to_lambda_loopnest (loops, loop_nest, &oldivs,
+                                               &invariants);
 
-      before = gcc_loopnest_to_lambda_loopnest (loops,
-                                               loop_nest, &oldivs, 
-                                               &invariants,
-                                               need_perfect_nest);
       if (!before)
-       continue;
-            
+       goto free_and_continue;
+
       if (dump_file)
        {
          fprintf (dump_file, "Before:\n");
@@ -342,10 +341,12 @@ linear_transform_loops (struct loops *loops)
 
       lambda_loopnest_to_gcc_loopnest (loop_nest, oldivs, invariants,
                                       after, trans);
+      modified = true;
 
       if (dump_file)
        fprintf (dump_file, "Successfully transformed loop.\n");
 
+    free_and_continue:
       free_dependence_relations (dependence_relations);
       free_data_refs (datarefs);
     }
@@ -353,5 +354,7 @@ linear_transform_loops (struct loops *loops)
   VEC_free (tree, heap, oldivs);
   VEC_free (tree, heap, invariants);
   scev_reset ();
-  rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_full_phi);
+
+  if (modified)
+    rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_full_phi);
 }