static bool poly_drs_may_alias_p (poly_dr_p pdr1, poly_dr_p pdr2) { ppl_Pointset_Powerset_C_Polyhedron_t alias_powerset1, alias_powerset2; ppl_Pointset_Powerset_C_Polyhedron_t accesses1 = PDR_ACCESSES (pdr1); ppl_Pointset_Powerset_C_Polyhedron_t accesses2 = PDR_ACCESSES (pdr2); ppl_dimension_type alias_dim1 = pdr_alias_set_dim (pdr1); ppl_dimension_type alias_dim2 = pdr_alias_set_dim (pdr2); int empty_p; ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron (&alias_powerset1, accesses1); ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron (&alias_powerset2, accesses2); build_alias_set_powerset (alias_powerset1, alias_dim1); build_alias_set_powerset (alias_powerset2, alias_dim2); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (alias_powerset1, alias_powerset2); empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (alias_powerset1); ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset1); ppl_delete_Pointset_Powerset_C_Polyhedron (alias_powerset2); return !empty_p; }
static void build_lexicographically_gt_constraint (ppl_Pointset_Powerset_C_Polyhedron_t *res, graphite_dim_t dim, graphite_dim_t tdim1, graphite_dim_t offset, bool direction) { graphite_dim_t i; if (lexicographically_gt_p (*res, dim, offset, direction, 0)) return; for (i = 0; i < tdim1 - 1; i++) { ppl_Pointset_Powerset_C_Polyhedron_t sceq; sceq = build_pairwise_scheduling_equality (dim, i, offset); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (*res, sceq); ppl_delete_Pointset_Powerset_C_Polyhedron (sceq); if (lexicographically_gt_p (*res, dim, offset, direction, i + 1)) return; } if (i == tdim1 - 1) { ppl_delete_Pointset_Powerset_C_Polyhedron (*res); ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (res, dim, 1); } }
static bool graphite_carried_dependence_level_k (poly_dr_p pdr1, poly_dr_p pdr2, int level) { poly_bb_p pbb1 = PDR_PBB (pdr1); poly_bb_p pbb2 = PDR_PBB (pdr2); ppl_Pointset_Powerset_C_Polyhedron_t d1 = PBB_DOMAIN (pbb1); ppl_Pointset_Powerset_C_Polyhedron_t d2 = PBB_DOMAIN (pbb2); ppl_Polyhedron_t so1 = PBB_TRANSFORMED_SCATTERING (pbb1); ppl_Polyhedron_t so2 = PBB_TRANSFORMED_SCATTERING (pbb2); ppl_Pointset_Powerset_C_Polyhedron_t po; ppl_Pointset_Powerset_C_Polyhedron_t eqpp; graphite_dim_t sdim1 = pdr_nb_subscripts (pdr1) + 1; graphite_dim_t sdim2 = pdr_nb_subscripts (pdr2) + 1; graphite_dim_t tdim1 = pbb_nb_scattering_transform (pbb1); graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1); ppl_dimension_type dim; bool empty_p; if ((PDR_TYPE (pdr1) == PDR_READ && PDR_TYPE (pdr2) == PDR_READ) || !poly_drs_may_alias_p (pdr1, pdr2)) return false; if (sdim1 != sdim2) return true; po = dependence_polyhedron (pbb1, pbb2, d1, d2, pdr1, pdr2, so1, so2, true, false); if (ppl_Pointset_Powerset_C_Polyhedron_is_empty (po)) { ppl_delete_Pointset_Powerset_C_Polyhedron (po); return false; } ppl_Pointset_Powerset_C_Polyhedron_space_dimension (po, &dim); eqpp = build_pairwise_scheduling_inequality (dim, level, tdim1 + ddim1, 1); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (eqpp, po); empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (eqpp); ppl_delete_Pointset_Powerset_C_Polyhedron (po); ppl_delete_Pointset_Powerset_C_Polyhedron (eqpp); return !empty_p; }
static bool lexicographically_gt_p (ppl_Pointset_Powerset_C_Polyhedron_t res, graphite_dim_t dim, graphite_dim_t offset, bool direction, graphite_dim_t i) { ppl_Pointset_Powerset_C_Polyhedron_t ineq; bool empty_p; ineq = build_pairwise_scheduling_inequality (dim, i, offset, direction); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (ineq, res); empty_p = ppl_Pointset_Powerset_C_Polyhedron_is_empty (ineq); if (!empty_p) ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, ineq); ppl_delete_Pointset_Powerset_C_Polyhedron (ineq); return !empty_p; }
static inline bool can_collapse_pdrs (poly_dr_p pdr1, poly_dr_p pdr2) { bool res; ppl_Pointset_Powerset_C_Polyhedron_t af1, af2, diff; if (PDR_PBB (pdr1) != PDR_PBB (pdr2) || PDR_NB_SUBSCRIPTS (pdr1) != PDR_NB_SUBSCRIPTS (pdr2) || PDR_TYPE (pdr1) != PDR_TYPE (pdr2)) return false; af1 = PDR_ACCESSES (pdr1); af2 = PDR_ACCESSES (pdr2); ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron (&diff, af1); ppl_Pointset_Powerset_C_Polyhedron_difference_assign (diff, af2); res = ppl_Pointset_Powerset_C_Polyhedron_is_empty (diff); ppl_delete_Pointset_Powerset_C_Polyhedron (diff); return res; }
static ppl_Pointset_Powerset_C_Polyhedron_t dependence_polyhedron_1 (poly_bb_p pbb1, poly_bb_p pbb2, ppl_Pointset_Powerset_C_Polyhedron_t d1, ppl_Pointset_Powerset_C_Polyhedron_t d2, poly_dr_p pdr1, poly_dr_p pdr2, ppl_Polyhedron_t s1, ppl_Polyhedron_t s2, bool direction, bool original_scattering_p) { scop_p scop = PBB_SCOP (pbb1); graphite_dim_t tdim1 = original_scattering_p ? pbb_nb_scattering_orig (pbb1) : pbb_nb_scattering_transform (pbb1); graphite_dim_t tdim2 = original_scattering_p ? pbb_nb_scattering_orig (pbb2) : pbb_nb_scattering_transform (pbb2); graphite_dim_t ddim1 = pbb_dim_iter_domain (pbb1); graphite_dim_t ddim2 = pbb_dim_iter_domain (pbb2); graphite_dim_t sdim1 = pdr_nb_subscripts (pdr1) + 1; graphite_dim_t gdim = scop_nb_params (scop); graphite_dim_t dim1 = pdr_dim (pdr1); graphite_dim_t dim2 = pdr_dim (pdr2); graphite_dim_t dim = tdim1 + tdim2 + dim1 + dim2; ppl_Pointset_Powerset_C_Polyhedron_t res; ppl_Pointset_Powerset_C_Polyhedron_t id1, id2, isc1, isc2, idr1, idr2; ppl_Pointset_Powerset_C_Polyhedron_t sc1, sc2, dreq; gcc_assert (PBB_SCOP (pbb1) == PBB_SCOP (pbb2)); ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc1, s1); ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&sc2, s2); id1 = map_into_dep_poly (dim, gdim, d1, ddim1, tdim1); id2 = map_into_dep_poly (dim, gdim, d2, ddim2, tdim1 + ddim1 + tdim2); isc1 = map_into_dep_poly (dim, gdim, sc1, ddim1 + tdim1, 0); isc2 = map_into_dep_poly (dim, gdim, sc2, ddim2 + tdim2, tdim1 + ddim1); idr1 = map_dr_into_dep_poly (dim, PDR_ACCESSES (pdr1), ddim1, ddim1 + gdim, tdim1, tdim2 + ddim2); idr2 = map_dr_into_dep_poly (dim, PDR_ACCESSES (pdr2), ddim2, ddim2 + gdim, tdim1 + ddim1 + tdim2, sdim1); /* Now add the subscript equalities. */ dreq = dr_equality_constraints (dim, tdim1 + ddim1 + tdim2 + ddim2, sdim1); ppl_new_Pointset_Powerset_C_Polyhedron_from_space_dimension (&res, dim, 0); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, id1); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, id2); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, isc1); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, isc2); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, idr1); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, idr2); ppl_Pointset_Powerset_C_Polyhedron_intersection_assign (res, dreq); ppl_delete_Pointset_Powerset_C_Polyhedron (id1); ppl_delete_Pointset_Powerset_C_Polyhedron (id2); ppl_delete_Pointset_Powerset_C_Polyhedron (sc1); ppl_delete_Pointset_Powerset_C_Polyhedron (sc2); ppl_delete_Pointset_Powerset_C_Polyhedron (isc1); ppl_delete_Pointset_Powerset_C_Polyhedron (isc2); ppl_delete_Pointset_Powerset_C_Polyhedron (idr1); ppl_delete_Pointset_Powerset_C_Polyhedron (idr2); ppl_delete_Pointset_Powerset_C_Polyhedron (dreq); if (!ppl_Pointset_Powerset_C_Polyhedron_is_empty (res)) build_lexicographically_gt_constraint (&res, dim, MIN (tdim1, tdim2), tdim1 + ddim1, direction); return res; }
void free_poly_dr (poly_dr_p pdr) { ppl_delete_Pointset_Powerset_C_Polyhedron (PDR_ACCESSES (pdr)); XDELETE (pdr); }