@@ -847,7 +847,8 @@ pbb_remove_duplicate_pdrs (poly_bb_p pbb)
void
new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
ppl_Pointset_Powerset_C_Polyhedron_t accesses,
- enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts)
+ enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts,
+ isl_map *acc, isl_set *extent)
{
static int id = 0;
poly_dr_p pdr = XNEW (struct poly_dr);
@@ -857,6 +858,8 @@ new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
PDR_NB_REFS (pdr) = 1;
PDR_PBB (pdr) = pbb;
PDR_ACCESSES (pdr) = accesses;
+ pdr->accesses = acc;
+ pdr->extent = extent;
PDR_TYPE (pdr) = type;
PDR_CDR (pdr) = cdr;
PDR_NB_SUBSCRIPTS (pdr) = nb_subscripts;
@@ -869,6 +872,8 @@ void
free_poly_dr (poly_dr_p pdr)
{
ppl_delete_Pointset_Powerset_C_Polyhedron (PDR_ACCESSES (pdr));
+ isl_map_free (pdr->accesses);
+ isl_set_free (pdr->extent);
XDELETE (pdr);
}
@@ -182,6 +182,7 @@ struct poly_dr
In the example, the vector "R C O I L P" is "7 7 3 2 0 1". */
ppl_Pointset_Powerset_C_Polyhedron_t _accesses;
isl_map *accesses;
+ isl_set *extent;
/* Data reference's base object set number, we must assure 2 pdrs are in the
same base object set before dependency checking. */
@@ -201,7 +202,8 @@ struct poly_dr
#define PDR_NB_SUBSCRIPTS(PDR) (PDR->nb_subscripts)
void new_poly_dr (poly_bb_p, int, ppl_Pointset_Powerset_C_Polyhedron_t,
- enum poly_dr_type, void *, graphite_dim_t);
+ enum poly_dr_type, void *, graphite_dim_t, isl_map *,
+ isl_set *);
void free_poly_dr (poly_dr_p);
void debug_pdr (poly_dr_p, int);
void print_pdr (FILE *, poly_dr_p, int);
@@ -658,6 +658,26 @@ isl_id_for_ssa_name (scop_p s, tree e)
return id;
}
+/* Return an ISL identifier for the data reference DR. */
+
+static isl_id *
+isl_id_for_dr (scop_p s, data_reference_p dr)
+{
+ isl_id *id;
+ const char *name = get_name (DR_BASE_OBJECT (dr));
+
+ if (name)
+ id = isl_id_alloc (s->ctx, name, dr);
+ else
+ {
+ char name1[1];
+ snprintf (name1, sizeof (name1), "A");
+ id = isl_id_alloc (s->ctx, name1, dr);
+ }
+
+ return id;
+}
+
/* Extract an affine expression from the ssa_name E. */
static isl_pw_aff *
@@ -1894,8 +1914,9 @@ build_scop_iteration_domain (scop_p scop)
ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
domain. */
-static void
-pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_map *
+pdr_add_alias_set (isl_map *acc,
+ ppl_Polyhedron_t accesses, data_reference_p dr,
ppl_dimension_type accessp_nb_dims,
ppl_dimension_type dom_nb_dims)
{
@@ -1916,6 +1937,34 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
ppl_delete_Linear_Expression (alias);
ppl_delete_Constraint (cstr);
+
+ {
+ isl_constraint *c = isl_equality_alloc (isl_map_get_dim (acc));
+ c = isl_constraint_set_constant_si (c, -alias_set_num);
+ c = isl_constraint_set_coefficient_si (c, isl_dim_out, 0, 1);
+
+ return isl_map_add_constraint (acc, c);
+ }
+}
+
+/* Assign the affine expression INDEX to the output dimension POS of
+ MAP and return the result. */
+
+static isl_map *
+set_index (isl_map *map, int pos, isl_pw_aff *index)
+{
+ isl_map *index_map;
+ int len = isl_map_dim (map, isl_dim_out);
+ isl_id *id;
+
+ index_map = isl_map_from_pw_aff (index);
+ index_map = isl_map_insert_dims (index_map, isl_dim_out, 0, pos);
+ index_map = isl_map_add_dims (index_map, isl_dim_out, len - pos - 1);
+
+ id = isl_map_get_tuple_id (map, isl_dim_out);
+ index_map = isl_map_set_tuple_id (index_map, isl_dim_out, id);
+
+ return isl_map_intersect (map, index_map);
}
/* Add to ACCESSES polyhedron equalities defining the access functions
@@ -1923,8 +1972,9 @@ pdr_add_alias_set (ppl_Polyhedron_t accesses, data_reference_p dr,
polyhedron, DOM_NB_DIMS is the dimension of the iteration domain.
PBB is the poly_bb_p that contains the data reference DR. */
-static void
-pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_map *
+pdr_add_memory_accesses (isl_map *acc,
+ ppl_Polyhedron_t accesses, data_reference_p dr,
ppl_dimension_type accessp_nb_dims,
ppl_dimension_type dom_nb_dims,
poly_bb_p pbb)
@@ -1957,9 +2007,13 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
ppl_delete_Linear_Expression (fn);
ppl_delete_Linear_Expression (access);
ppl_delete_Constraint (cstr);
+
+ acc = set_index (acc, i + 1, extract_affine (scop, afn));
}
mpz_clear (v);
+
+ return acc;
}
/* Add constrains representing the size of the accessed data to the
@@ -1967,8 +2021,9 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
ACCESSES polyhedron, DOM_NB_DIMS is the dimension of the iteration
domain. */
-static void
-pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
+static isl_set *
+pdr_add_data_dimensions (isl_set *extent, scop_p scop,
+ ppl_Polyhedron_t accesses, data_reference_p dr,
ppl_dimension_type accessp_nb_dims,
ppl_dimension_type dom_nb_dims)
{
@@ -2006,6 +2061,52 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
high = array_ref_up_bound (ref);
+ if (host_integerp (low, 0)
+ && high
+ && host_integerp (high, 0)
+ /* 1-element arrays at end of structures may extend over
+ their declared size. */
+ && !(array_at_struct_end_p (ref)
+ && operand_equal_p (low, high, 0)))
+ {
+ isl_id *id;
+ isl_aff *aff;
+ isl_set *univ, *lbs, *ubs;
+ isl_pw_aff *index;
+ isl_dim *dim;
+ isl_set *valid;
+ int nbl = isl_set_dim (scop->context, isl_dim_set);
+ int nbs = isl_set_dim (extent, isl_dim_set);
+ isl_pw_aff *lb = extract_affine_int (scop, low);
+ isl_pw_aff *ub = extract_affine_int (scop, high);
+
+ /* high >= 0 */
+ valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
+ scop->context = isl_set_intersect (scop->context, valid);
+
+ /* Make the dimension of LB and UB to be exactly NBS. */
+ lb = isl_pw_aff_drop_dims (lb, isl_dim_set, 0, nbl - 1);
+ ub = isl_pw_aff_drop_dims (ub, isl_dim_set, 0, nbl - 1);
+ lb = isl_pw_aff_add_dims (lb, isl_dim_set, nbs - 1);
+ ub = isl_pw_aff_add_dims (ub, isl_dim_set, nbs - 1);
+
+ dim = isl_set_get_dim (extent);
+ aff = isl_aff_zero (isl_local_space_from_dim (dim));
+ aff = isl_aff_add_coefficient_si (aff, isl_dim_set, i, 1);
+ univ = isl_set_universe (isl_aff_get_dim (aff));
+ index = isl_pw_aff_alloc (univ, aff);
+
+ id = isl_set_get_tuple_id (extent);
+ lb = isl_pw_aff_set_tuple_id (lb, isl_id_copy (id));
+ ub = isl_pw_aff_set_tuple_id (ub, id);
+
+ /* low <= sub_i <= high */
+ lbs = isl_pw_aff_ge_set (isl_pw_aff_copy (index), lb);
+ ubs = isl_pw_aff_le_set (index, ub);
+ extent = isl_set_intersect (extent, lbs);
+ extent = isl_set_intersect (extent, ubs);
+ }
+
/* high - subscript >= 0 */
if (high && host_integerp (high, 0)
/* 1-element arrays at end of structures may extend over
@@ -2024,6 +2125,8 @@ pdr_add_data_dimensions (ppl_Polyhedron_t accesses, data_reference_p dr,
ppl_delete_Constraint (cstr);
}
}
+
+ return extent;
}
/* Build data accesses for DR in PBB. */
@@ -2036,6 +2139,9 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
ppl_dimension_type dom_nb_dims;
ppl_dimension_type accessp_nb_dims;
int dr_base_object_set;
+ isl_map *acc;
+ isl_set *extent;
+ scop_p scop = PBB_SCOP (pbb);
ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb),
&dom_nb_dims);
@@ -2043,9 +2149,29 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
ppl_new_C_Polyhedron_from_space_dimension (&accesses, accessp_nb_dims, 0);
- pdr_add_alias_set (accesses, dr, accessp_nb_dims, dom_nb_dims);
- pdr_add_memory_accesses (accesses, dr, accessp_nb_dims, dom_nb_dims, pbb);
- pdr_add_data_dimensions (accesses, dr, accessp_nb_dims, dom_nb_dims);
+ {
+ isl_dim *dc = isl_set_get_dim (scop->context);
+ int nb_out = 1 + DR_NUM_DIMENSIONS (dr);
+ isl_dim *dim = isl_dim_add (isl_dim_from_domain (dc), isl_dim_out, nb_out);
+
+ acc = isl_map_universe (dim);
+ acc = isl_map_set_tuple_id (acc, isl_dim_out, isl_id_for_dr (scop, dr));
+ }
+
+ acc = pdr_add_alias_set (acc, accesses, dr, accessp_nb_dims, dom_nb_dims);
+ acc = pdr_add_memory_accesses (acc, accesses, dr, accessp_nb_dims,
+ dom_nb_dims, pbb);
+
+ {
+ isl_id *id = isl_id_for_dr (scop, dr);
+ int nb = 1 + DR_NUM_DIMENSIONS (dr);
+ isl_dim *dim = isl_dim_set_alloc (scop->ctx, 0, nb);
+
+ dim = isl_dim_set_tuple_id (dim, isl_dim_set, id);
+ extent = isl_set_nat_universe (dim);
+ extent = pdr_add_data_dimensions (extent, scop, accesses, dr,
+ accessp_nb_dims, dom_nb_dims);
+ }
ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&accesses_ps,
accesses);
@@ -2056,7 +2182,7 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
new_poly_dr (pbb, dr_base_object_set, accesses_ps,
DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
- dr, DR_NUM_DIMENSIONS (dr));
+ dr, DR_NUM_DIMENSIONS (dr), acc, extent);
}
/* Write to FILE the alias graph of data references in DIMACS format. */
Signed-off-by: Sebastian Pop <sebpop@gmail.com> --- gcc/graphite-poly.c | 7 ++- gcc/graphite-poly.h | 4 +- gcc/graphite-sese-to-poly.c | 146 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 145 insertions(+), 12 deletions(-)