summaryrefslogtreecommitdiff
path: root/gcc/graphite-poly.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-28 20:40:59 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2009-08-28 20:40:59 +0000
commit11b2102e59b93c1ed672c312d6f40ecc7382d3db (patch)
treef4bc77546493208666cd3b4afa7a90ecb6195f6a /gcc/graphite-poly.c
parentd0aaf3990d011abe5d7c65905f240a60d2fdccb6 (diff)
downloadgcc-11b2102e59b93c1ed672c312d6f40ecc7382d3db.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151191 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-poly.c')
-rw-r--r--gcc/graphite-poly.c60
1 files changed, 58 insertions, 2 deletions
diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c
index 21bba6c6eae..3e005d41da7 100644
--- a/gcc/graphite-poly.c
+++ b/gcc/graphite-poly.c
@@ -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;