]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
graphite-interchange.c (pbb_interchange_profitable_p): Adjust the strides by multiply...
authorSebastian Pop <sebastian.pop@amd.com>
Fri, 28 Aug 2009 20:40:59 +0000 (20:40 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 28 Aug 2009 20:40:59 +0000 (20:40 +0000)
2009-08-28  Sebastian Pop  <sebastian.pop@amd.com>

* graphite-interchange.c (pbb_interchange_profitable_p): Adjust
the strides by multiplying by PDR_NB_REFS.
* graphite-poly.c (can_collapse_pdr): New.
(pdr_find_duplicate): New.
(new_poly_dr): Call pdr_find_duplicate.  Collapse duplicate PDRs.
Initialize PDR_NB_REFS.
* graphite-poly.h (struct poly_dr): Add field nb_refs.
(PDR_NB_REFS): New.
(new_poly_dr): Number of subscripts is a graphite_dim_t.

From-SVN: r151191

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

index 715cb56faba682a886324da7e0d626742b71035a..d8df593c912f8539df8dcf9c360bee3190318279 100644 (file)
@@ -1,3 +1,15 @@
+2009-08-28  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * graphite-interchange.c (pbb_interchange_profitable_p): Adjust
+       the strides by multiplying by PDR_NB_REFS.
+       * graphite-poly.c (can_collapse_pdr): New.
+       (pdr_find_duplicate): New.
+       (new_poly_dr): Call pdr_find_duplicate.  Collapse duplicate PDRs.
+       Initialize PDR_NB_REFS.
+       * graphite-poly.h (struct poly_dr): Add field nb_refs.
+       (PDR_NB_REFS): New.
+       (new_poly_dr): Number of subscripts is a graphite_dim_t.
+
 2009-08-28  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR middle-end/40965
index 06ae6776a30cc2a40312969146f0253b728ed035..c7b8fcf675be9a8dbba5e6b5b8b96755b903bc8d 100644 (file)
@@ -1,3 +1,22 @@
+2009-08-25  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * graphite-interchange.c (pbb_interchange_profitable_p): Adjust
+       the strides by multiplying by PDR_NB_REFS.
+       * graphite-poly.c (can_collapse_pdr): New.
+       (pdr_find_duplicate): New.
+       (new_poly_dr): Call pdr_find_duplicate.  Collapse duplicate PDRs.
+       Initialize PDR_NB_REFS.
+       * graphite-poly.h (struct poly_dr): Add field nb_refs.
+       (PDR_NB_REFS): New.
+       (new_poly_dr): Number of subscripts is a graphite_dim_t.
+
+2009-08-25  Sebastian Pop  <sebastian.pop@amd.com>
+
+       Revert one of the previous commits:
+       * graphite-dependences.c (graphite_legal_transform_bb): Avoid
+       the computation of symmetric data dependence relations.
+       (dependency_between_pbbs_p): Same.
+
 2009-08-25  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR middle-end/40965
index bf944c80f20893a8660adba9f994363ab5a68719..0a751d6336e98ffe9d726dee0468037ce2b77c14 100644 (file)
@@ -244,7 +244,7 @@ pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2,
 {
   int i;
   poly_dr_p pdr;
-  Value d1, d2, s;
+  Value d1, d2, s, n;
   bool res;
 
   gcc_assert (depth1 < depth2);
@@ -254,13 +254,18 @@ pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2,
   value_init (d2);
   value_set_si (d2, 0);
   value_init (s);
+  value_init (n);
 
   for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++)
     {
+      value_set_si (n, PDR_NB_REFS (pdr));
+
       memory_stride_in_loop (s, depth1, pdr);
+      value_multiply (s, s, n);
       value_addto (d1, d1, s);
 
       memory_stride_in_loop (s, depth2, pdr);
+      value_multiply (s, s, n);
       value_addto (d2, d2, s);
     }
 
@@ -269,6 +274,7 @@ pbb_interchange_profitable_p (graphite_dim_t depth1, graphite_dim_t depth2,
   value_clear (d1);
   value_clear (d2);
   value_clear (s);
+  value_clear (n);
 
   return res;
 }
index 21bba6c6eae1b7e333a2795d5412ba468a94d75e..3e005d41da7e8926beb5e3b6cdbfce8dca235a7c 100644 (file)
@@ -261,6 +261,53 @@ apply_poly_transforms (scop_p scop)
   return transform_done;
 }
 
+/* Returns true when PDR in the same PBB and is a duplicate of the
+   data reference described by ACCESSES, TYPE, and NB_SUBSCRIPTS.  */
+
+static inline bool
+can_collapse_pdr (poly_dr_p pdr, poly_bb_p pbb,
+                 ppl_Pointset_Powerset_C_Polyhedron_t accesses,
+                 enum poly_dr_type type, graphite_dim_t nb_subscripts)
+{
+  bool res = false;
+  ppl_Pointset_Powerset_C_Polyhedron_t af, diff;
+
+  if (PDR_PBB (pdr) != pbb
+      || PDR_NB_SUBSCRIPTS (pdr) != nb_subscripts
+      || PDR_TYPE (pdr) != type)
+    return false;
+
+  ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
+    (&diff, accesses);
+  af = PDR_ACCESSES (pdr);
+  ppl_Pointset_Powerset_C_Polyhedron_difference_assign (diff, af);
+
+  if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (diff))
+    res = true;
+
+  ppl_delete_Pointset_Powerset_C_Polyhedron (diff);
+  return res;
+}
+
+/* Returns a duplicate of the data reference described by ACCESSES,
+   TYPE, and NB_SUBSCRIPTS in the vector PBB_DRS (PBB).  If there is
+   no duplicate, returns NULL.  */
+
+static inline poly_dr_p
+pdr_find_duplicate (poly_bb_p pbb,
+                   ppl_Pointset_Powerset_C_Polyhedron_t accesses,
+                   enum poly_dr_type type, graphite_dim_t nb_subscripts)
+{
+  int i;
+  poly_dr_p pdr;
+
+  for (i = 0; VEC_iterate (poly_dr_p, PBB_DRS (pbb), i, pdr); i++)
+    if (can_collapse_pdr (pdr, pbb, accesses, type, nb_subscripts))
+      return pdr;
+
+  return NULL;
+}
+
 /* Create a new polyhedral data reference and add it to PBB.  It is
    defined by its ACCESSES, its TYPE, and the number of subscripts
    NB_SUBSCRIPTS.  */
@@ -268,12 +315,21 @@ apply_poly_transforms (scop_p scop)
 void
 new_poly_dr (poly_bb_p pbb,
             ppl_Pointset_Powerset_C_Polyhedron_t accesses,
-            enum poly_dr_type type, void *cdr, int nb_subscripts)
+            enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts)
 {
-  poly_dr_p pdr = XNEW (struct poly_dr);
   static int id = 0;
+  poly_dr_p pdr;
+  poly_dr_p same = pdr_find_duplicate (pbb, accesses, type, nb_subscripts);
+
+  if (same)
+    {
+      PDR_NB_REFS (same) += 1;
+      return;
+    }
 
+  pdr = XNEW (struct poly_dr);
   PDR_ID (pdr) = id++;
+  PDR_NB_REFS (pdr) = 1;
   PDR_PBB (pdr) = pbb;
   PDR_ACCESSES (pdr) = accesses;
   PDR_TYPE (pdr) = type;
index 10831afde8eee50dfdce8b442cd10018febecc34..8f7352a5efbab0266b0bf4684afa8dcc56b953f2 100644 (file)
@@ -56,6 +56,9 @@ struct poly_dr
   /* An identifier for this PDR.  */
   int id;
 
+  /* The number of data refs identical to this one in the PBB.  */
+  int nb_refs;
+
   /* A pointer to compiler's data reference description.  */
   void *compiler_dr;
 
@@ -137,6 +140,7 @@ struct poly_dr
 };
 
 #define PDR_ID(PDR) (PDR->id)
+#define PDR_NB_REFS(PDR) (PDR->nb_refs)
 #define PDR_CDR(PDR) (PDR->compiler_dr)
 #define PDR_PBB(PDR) (PDR->pbb)
 #define PDR_TYPE(PDR) (PDR->type)
@@ -144,7 +148,7 @@ struct poly_dr
 #define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
 
 void new_poly_dr (poly_bb_p, ppl_Pointset_Powerset_C_Polyhedron_t,
-                 enum poly_dr_type, void *, int);
+                 enum poly_dr_type, void *, graphite_dim_t);
 void free_poly_dr (poly_dr_p);
 void debug_pdr (poly_dr_p);
 void print_pdr (FILE *, poly_dr_p);