Memoize memory strides per loop.
authorSebastian Pop <sebastian.pop@amd.com>
Fri, 8 Jan 2010 04:35:43 +0000 (04:35 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 8 Jan 2010 04:35:43 +0000 (04:35 +0000)
2010-01-07  Sebastian Pop  <sebastian.pop@amd.com>

* graphite-interchange.c (memory_stride_in_loop): Renamed
pdr_stride_in_loop.
(memory_strides_in_loop): Renamed memory_strides_in_loop_1.
(memory_strides_in_loop): Memoize the memory strides per loop.
(lst_interchange_profitable_p): Do not initialize to zero the memory
strides.
* graphite-poly.h (struct lst): Add a field memory_strides.
(LST_LOOP_MEMORY_STRIDES): New.
(new_lst_loop): Initialize LST_LOOP_MEMORY_STRIDES to -1.
(free_lst): Clear LST_LOOP_MEMORY_STRIDES.

From-SVN: r155725

gcc/ChangeLog.graphite
gcc/graphite-interchange.c
gcc/graphite-poly.h

index ea58308..379e351 100644 (file)
@@ -1,5 +1,18 @@
 2010-01-07  Sebastian Pop  <sebastian.pop@amd.com>
 
+       * graphite-interchange.c (memory_stride_in_loop): Renamed
+       pdr_stride_in_loop.
+       (memory_strides_in_loop): Renamed memory_strides_in_loop_1.
+       (memory_strides_in_loop): Memoize the memory strides per loop.
+       (lst_interchange_profitable_p): Do not initialize to zero the memory
+       strides.
+       * graphite-poly.h (struct lst): Add a field memory_strides.
+       (LST_LOOP_MEMORY_STRIDES): New.
+       (new_lst_loop): Initialize LST_LOOP_MEMORY_STRIDES to -1.
+       (free_lst): Clear LST_LOOP_MEMORY_STRIDES.
+
+2010-01-07  Sebastian Pop  <sebastian.pop@amd.com>
+
        * graphite-interchange.c (memory_strides_in_loop_depth): Renamed
        memory_strides_in_loop.  Gather memory strides on a whole loop.
        (pbb_interchange_profitable_p): Renamed lst_interchange_profitable_p.
index 90982f8..918e334 100644 (file)
@@ -196,7 +196,7 @@ build_partial_difference (ppl_Pointset_Powerset_C_Polyhedron_t *p,
    the loop at DEPTH.  */
 
 static void
-memory_stride_in_loop (Value stride, graphite_dim_t depth, poly_dr_p pdr)
+pdr_stride_in_loop (Value stride, graphite_dim_t depth, poly_dr_p pdr)
 {
   ppl_dimension_type time_depth;
   ppl_Linear_Expression_t le, lma;
@@ -329,11 +329,12 @@ memory_stride_in_loop (Value stride, graphite_dim_t depth, poly_dr_p pdr)
   ppl_delete_Linear_Expression (le);
 }
 
+
 /* Sets STRIDES to the sum of all the strides of the data references
    accessed in LOOP at DEPTH.  */
 
 static void
-memory_strides_in_loop (lst_p loop, graphite_dim_t depth, Value strides)
+memory_strides_in_loop_1 (lst_p loop, graphite_dim_t depth, Value strides)
 {
   int i, j;
   lst_p l;
@@ -345,11 +346,11 @@ memory_strides_in_loop (lst_p loop, graphite_dim_t depth, Value strides)
 
   for (j = 0; VEC_iterate (lst_p, LST_SEQ (loop), j, l); j++)
     if (LST_LOOP_P (l))
-      memory_strides_in_loop (l, depth, strides);
+      memory_strides_in_loop_1 (l, depth, strides);
     else
       for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (LST_PBB (l)), i, pdr); i++)
        {
-         memory_stride_in_loop (s, depth, pdr);
+         pdr_stride_in_loop (s, depth, pdr);
          value_set_si (n, PDR_NB_REFS (pdr));
          value_multiply (s, s, n);
          value_addto (strides, strides, s);
@@ -359,6 +360,21 @@ memory_strides_in_loop (lst_p loop, graphite_dim_t depth, Value strides)
   value_clear (n);
 }
 
+/* Sets STRIDES to the sum of all the strides of the data references
+   accessed in LOOP at DEPTH.  */
+
+static void
+memory_strides_in_loop (lst_p loop, graphite_dim_t depth, Value strides)
+{
+  if (value_mone_p (loop->memory_strides))
+    {
+      value_set_si (strides, 0);
+      memory_strides_in_loop_1 (loop, depth, strides);
+    }
+  else
+    value_assign (strides, loop->memory_strides);
+}
+
 /* Return true when the interchange of loops LOOP1 and LOOP2 is
    profitable.
 
@@ -452,8 +468,6 @@ lst_interchange_profitable_p (lst_p loop1, lst_p loop2)
 
   value_init (d1);
   value_init (d2);
-  value_set_si (d1, 0);
-  value_set_si (d2, 0);
 
   memory_strides_in_loop (loop1, lst_depth (loop1), d1);
   memory_strides_in_loop (loop2, lst_depth (loop2), d2);
index 4912801..a2969c7 100644 (file)
@@ -632,6 +632,9 @@ struct lst {
   /* A pointer to the loop that contains this node.  */
   lst_p loop_father;
 
+  /* The sum of all the memory strides for an LST loop.  */
+  Value memory_strides;
+
   /* Loop nodes contain a sequence SEQ of LST nodes, statements
      contain a pointer to their polyhedral representation PBB.  */
   union {
@@ -644,6 +647,7 @@ struct lst {
 #define LST_LOOP_FATHER(LST) ((LST)->loop_father)
 #define LST_PBB(LST) ((LST)->node.pbb)
 #define LST_SEQ(LST) ((LST)->node.seq)
+#define LST_LOOP_MEMORY_STRIDES(LST) ((LST)->memory_strides)
 
 void scop_to_lst (scop_p);
 void print_lst (FILE *, lst_p, int);
@@ -662,6 +666,8 @@ new_lst_loop (VEC (lst_p, heap) *seq)
   LST_LOOP_P (lst) = true;
   LST_SEQ (lst) = seq;
   LST_LOOP_FATHER (lst) = NULL;
+  value_init (LST_LOOP_MEMORY_STRIDES (lst));
+  value_set_si (LST_LOOP_MEMORY_STRIDES (lst), -1);
 
   for (i = 0; VEC_iterate (lst_p, seq, i, l); i++)
     LST_LOOP_FATHER (l) = lst;
@@ -698,6 +704,7 @@ free_lst (lst_p lst)
       for (i = 0; VEC_iterate (lst_p, LST_SEQ (lst), i, l); i++)
        free_lst (l);
 
+      value_clear (LST_LOOP_MEMORY_STRIDES (lst));
       VEC_free (lst_p, heap, LST_SEQ (lst));
     }