]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
graphite.c (compare_prefix_loops): New.
authorSebastian Pop <sebastian.pop@amd.com>
Fri, 16 Jan 2009 15:20:16 +0000 (15:20 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 16 Jan 2009 15:20:16 +0000 (15:20 +0000)
2009-01-16  Sebastian Pop  <sebastian.pop@amd.com>
    Tobias Grosser  <tobi.grosser@amd.com>

* graphite.c (compare_prefix_loops): New.
(build_scop_canonical_schedules): Rewritten.
(graphite_transform_loops): Move build_scop_canonical_schedules
after build_scop_iteration_domain.

Co-Authored-By: Tobias Grosser <tobi.grosser@amd.com>
From-SVN: r143437

gcc/ChangeLog
gcc/graphite.c

index 0dd888d4519f22e448d65e1a4cda5c54f930dc15..b6e30e058eb2ded8cf76f86fe00717bc12a00d28 100644 (file)
@@ -1,3 +1,11 @@
+2009-01-16  Sebastian Pop  <sebastian.pop@amd.com>
+           Tobias Grosser  <tobi.grosser@amd.com>
+
+       * graphite.c (compare_prefix_loops): New.
+       (build_scop_canonical_schedules): Rewritten.
+       (graphite_transform_loops): Move build_scop_canonical_schedules
+       after build_scop_iteration_domain.
+
 2009-01-16  Sebastian Pop  <sebastian.pop@amd.com>
            Tobias Grosser  <tobi.grosser@amd.com>
 
index b90abf1fef36962d0748cab17689e5a6ac7b5b97..4e301e47c542e6f8bbc1a3ba8b11edca5b33cb2d 100644 (file)
@@ -2472,6 +2472,29 @@ build_scop_dynamic_schedules (scop_p scop)
     }
 }
 
+/* Returns the number of loops that are identical at the beginning of
+   the vectors A and B.  */
+
+static int
+compare_prefix_loops (VEC (loop_p, heap) *a, VEC (loop_p, heap) *b)
+{
+  int i;
+  loop_p ea;
+  int lb;
+
+  if (!a || !b)
+    return 0;
+
+  lb = VEC_length (loop_p, b);
+
+  for (i = 0; VEC_iterate (loop_p, a, i, ea); i++)
+    if (i >= lb
+       || ea != VEC_index (loop_p, b, i))
+      return i;
+
+  return 0;
+}
+
 /* Build for BB the static schedule.
 
    The STATIC_SCHEDULE is defined like this:
@@ -2508,34 +2531,29 @@ build_scop_dynamic_schedules (scop_p scop)
 static void
 build_scop_canonical_schedules (scop_p scop)
 {
-  int i, j;
+  int i;
   graphite_bb_p gb;
-  int nb = scop_nb_loops (scop) + 1;
+  int nb_loops = scop_nb_loops (scop);
+  lambda_vector static_schedule = lambda_vector_new (nb_loops + 1);
+  VEC (loop_p, heap) *loops_previous = NULL;
 
-  SCOP_STATIC_SCHEDULE (scop) = lambda_vector_new (nb);
+  /* We have to start schedules at 0 on the first component and
+     because we cannot compare_prefix_loops against a previous loop,
+     prefix will be equal to zero, and that index will be
+     incremented before copying.  */
+  static_schedule[0] = -1;
 
   for (i = 0; VEC_iterate (graphite_bb_p, SCOP_BBS (scop), i, gb); i++)
     {
-      int offset = nb_loops_around_gb (gb);
-
-      /* After leaving a loop, it is possible that the schedule is not
-        set at zero.  This loop reinitializes components located
-        after OFFSET.  */
-
-      for (j = offset + 1; j < nb; j++)
-       if (SCOP_STATIC_SCHEDULE (scop)[j])
-         {
-           memset (&(SCOP_STATIC_SCHEDULE (scop)[j]), 0,
-                   sizeof (int) * (nb - j));
-           ++SCOP_STATIC_SCHEDULE (scop)[offset];
-           break;
-         }
-
-      GBB_STATIC_SCHEDULE (gb) = lambda_vector_new (offset + 1);
-      lambda_vector_copy (SCOP_STATIC_SCHEDULE (scop), 
-                         GBB_STATIC_SCHEDULE (gb), offset + 1);
-
-      ++SCOP_STATIC_SCHEDULE (scop)[offset];
+      int prefix = compare_prefix_loops (loops_previous, GBB_LOOPS (gb));
+      int nb = gbb_nb_loops (gb);
+
+      loops_previous = GBB_LOOPS (gb);
+      memset (&(static_schedule[prefix + 1]), 0, sizeof (int) * (nb_loops - prefix));
+      ++static_schedule[prefix];
+      GBB_STATIC_SCHEDULE (gb) = lambda_vector_new (nb + 1);
+      lambda_vector_copy (static_schedule, 
+                         GBB_STATIC_SCHEDULE (gb), nb + 1);
     }
 }
 
@@ -6049,7 +6067,6 @@ graphite_transform_loops (void)
       if (!build_scop_loop_nests (scop))
        continue;
 
-      build_scop_canonical_schedules (scop);
       build_bb_loops (scop);
 
       if (!build_scop_conditions (scop))
@@ -6071,6 +6088,7 @@ graphite_transform_loops (void)
        continue;
 
       add_conditions_to_constraints (scop);
+      build_scop_canonical_schedules (scop);
 
       build_scop_data_accesses (scop);
       build_scop_dynamic_schedules (scop);