From patchwork Thu Aug 11 22:44:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 109704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6F403B6F68 for ; Fri, 12 Aug 2011 08:46:10 +1000 (EST) Received: (qmail 31441 invoked by alias); 11 Aug 2011 22:45:50 -0000 Received: (qmail 30772 invoked by uid 22791); 11 Aug 2011 22:45:41 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_GB, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Aug 2011 22:45:20 +0000 Received: by gyg4 with SMTP id 4so1748594gyg.20 for ; Thu, 11 Aug 2011 15:45:19 -0700 (PDT) Received: by 10.151.149.16 with SMTP id b16mr1184595ybo.419.1313102719807; Thu, 11 Aug 2011 15:45:19 -0700 (PDT) Received: from napoca ([163.181.251.115]) by mx.google.com with ESMTPS id o4sm1398211ybc.15.2011.08.11.15.45.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 11 Aug 2011 15:45:19 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Thu, 11 Aug 2011 17:45:16 -0500 From: Sebastian Pop To: skimo@kotnet.org, tobias@grosser.es Cc: gcc-patches@gcc.gnu.org, Sebastian Pop Subject: [PATCH 10/11] add pbb->domain Date: Thu, 11 Aug 2011 17:44:38 -0500 Message-Id: <1313102679-32012-11-git-send-email-sebpop@gmail.com> In-Reply-To: <1313102679-32012-1-git-send-email-sebpop@gmail.com> References: <20110811220610.GN14955MdfPADPa@purples> <1313102679-32012-1-git-send-email-sebpop@gmail.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Signed-off-by: Sebastian Pop --- gcc/graphite-poly.c | 12 ++++- gcc/graphite-poly.h | 6 ++ gcc/graphite-sese-to-poly.c | 122 ++++++++++++++++++++++++++++++------------ 3 files changed, 104 insertions(+), 36 deletions(-) diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index fd2703b..ce0649b 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -880,6 +880,7 @@ new_poly_bb (scop_p scop, void *black_box) poly_bb_p pbb = XNEW (struct poly_bb); PBB_DOMAIN (pbb) = NULL; + pbb->domain = NULL; PBB_SCOP (pbb) = scop; pbb_set_black_box (pbb, black_box); PBB_TRANSFORMED (pbb) = NULL; @@ -901,7 +902,10 @@ free_poly_bb (poly_bb_p pbb) int i; poly_dr_p pdr; - ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb)); + if (PBB_DOMAIN (pbb)) + ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb)); + + isl_set_free (pbb->domain); if (PBB_TRANSFORMED (pbb)) poly_scattering_free (PBB_TRANSFORMED (pbb)); @@ -1096,6 +1100,12 @@ print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity) graphite_dim_t i; gimple_bb_p gbb = PBB_BLACK_BOX (pbb); + { + isl_printer *pp = isl_printer_to_file (PBB_SCOP (pbb)->ctx, file); + pp = isl_printer_print_set (pp, pbb->domain); + isl_printer_free (pp); + } + if (!PBB_DOMAIN (pbb)) return; diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h index bb8771d..3483ef0 100644 --- a/gcc/graphite-poly.h +++ b/gcc/graphite-poly.h @@ -502,6 +502,12 @@ pbb_dim_iter_domain (const struct poly_bb *pbb) { scop_p scop = PBB_SCOP (pbb); ppl_dimension_type dim; + isl_dim *d = isl_set_get_dim (pbb->domain); + graphite_dim_t res = isl_dim_size (d, isl_dim_set); + + isl_dim_free (d); + if (0) + return res; ppl_Pointset_Powerset_C_Polyhedron_space_dimension (PBB_DOMAIN (pbb), &dim); return dim - scop_nb_params (scop); diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 69392a9..75355e9 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -658,20 +658,6 @@ isl_id_for_ssa_name (scop_p s, tree e) return id; } -/* Return an ISL identifier from the loop L. */ - -static isl_id * -isl_id_for_loop (scop_p s, loop_p l) -{ - isl_id *id; - char name[50]; - - snprintf (name, sizeof (name), "L_%d", l ? l->num : -1); - id = isl_id_alloc (s->ctx, name, l); - - return id; -} - /* Extract an affine expression from the ssa_name E. */ static isl_pw_aff * @@ -1182,10 +1168,6 @@ find_scop_parameters (scop_p scop) dim = isl_dim_set_dim_id (dim, isl_dim_param, i, isl_id_for_ssa_name (scop, e)); - for (i = 0; i < nbl; i++) - dim = isl_dim_set_dim_id (dim, isl_dim_set, i, - isl_id_for_loop (scop, get_loop (i))); - scop->context = isl_set_universe (dim); } } @@ -1263,7 +1245,8 @@ add_upper_bounds_from_estimated_nit (scop_p scop, double_int nit, static void build_loop_iteration_domains (scop_p scop, struct loop *loop, ppl_Polyhedron_t outer_ph, int nb, - ppl_Pointset_Powerset_C_Polyhedron_t *domains) + ppl_Pointset_Powerset_C_Polyhedron_t *domains, + isl_set *outer, isl_set **doms) { int i; ppl_Polyhedron_t ph; @@ -1271,6 +1254,15 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, ppl_dimension_type dim = nb + 1 + scop_nb_params (scop); sese region = SCOP_REGION (scop); + isl_set *inner = isl_set_copy (outer); + isl_dim *dimension = isl_set_get_dim (scop->context); + int pos = loop->num; + isl_int v; + mpz_t g; + + mpz_init (g); + isl_int_init (v); + { ppl_const_Constraint_System_t pcs; ppl_dimension_type *map @@ -1301,8 +1293,17 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, ppl_delete_Linear_Expression (lb_expr); ppl_Polyhedron_add_constraint (ph, lb); ppl_delete_Constraint (lb); + + { + isl_constraint *c = isl_inequality_alloc (isl_dim_copy (dimension)); + + isl_int_set_si (v, 1); + isl_constraint_set_coefficient (c, isl_dim_set, pos, v); + inner = isl_set_add_constraint (inner, c); + } } + /* loop_i <= cst_nb_iters */ if (TREE_CODE (nb_iters) == INTEGER_CST) { ppl_Constraint_t ub; @@ -1310,14 +1311,26 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, ppl_new_Linear_Expression_with_dimension (&ub_expr, dim); - /* loop_i <= cst_nb_iters */ ppl_set_coef (ub_expr, nb, -1); ppl_set_inhomogeneous_tree (ub_expr, nb_iters); ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL); ppl_Polyhedron_add_constraint (ph, ub); ppl_delete_Linear_Expression (ub_expr); ppl_delete_Constraint (ub); + + { + isl_constraint *c = isl_inequality_alloc (isl_dim_copy (dimension)); + + isl_int_set_si (v, -1); + isl_constraint_set_coefficient (c, isl_dim_set, pos, v); + tree_int_to_gmp (nb_iters, g); + isl_int_set_gmp (v, g); + isl_constraint_set_constant (c, v); + inner = isl_set_add_constraint (inner, c); + } } + + /* loop_i <= expr_nb_iters */ else if (!chrec_contains_undetermined (nb_iters)) { mpz_t one; @@ -1337,6 +1350,15 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, scop->context = isl_set_intersect (scop->context, isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff))); + { + isl_local_space *ls = isl_local_space_from_dim (isl_dim_copy (dimension)); + isl_aff *al = isl_aff_set_coefficient_si + (isl_aff_zero (ls), isl_dim_set, pos, 1); + isl_set *le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al), + isl_pw_aff_copy (aff)); + inner = isl_set_intersect (inner, le); + } + if (max_stmt_executions (loop, true, &nit)) { add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr); @@ -1361,7 +1383,6 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, } } - /* loop_i <= expr_nb_iters */ ppl_set_coef (ub_expr, nb, -1); ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL); ppl_Polyhedron_add_constraint (ph, ub); @@ -1372,17 +1393,27 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop, gcc_unreachable (); if (loop->inner && loop_in_sese_p (loop->inner, region)) - build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains); + build_loop_iteration_domains (scop, loop->inner, ph, nb + 1, domains, + isl_set_copy (inner), doms); if (nb != 0 && loop->next && loop_in_sese_p (loop->next, region)) - build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains); + build_loop_iteration_domains (scop, loop->next, outer_ph, nb, domains, + isl_set_copy (outer), doms); ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron (&domains[loop->num], ph); - ppl_delete_Polyhedron (ph); + + gcc_assert (doms[loop->num] == NULL); + doms[loop->num] = isl_set_copy (inner); + + isl_set_free (inner); + isl_set_free (outer); + isl_dim_free (dimension); + isl_int_clear (v); + mpz_clear (g); } /* Returns a linear expression for tree T evaluated in PBB. */ @@ -1812,31 +1843,50 @@ build_scop_iteration_domain (scop_p scop) int nb_loops = number_of_loops (); ppl_Pointset_Powerset_C_Polyhedron_t *domains = XNEWVEC (ppl_Pointset_Powerset_C_Polyhedron_t, nb_loops); + isl_set **doms = XNEWVEC (isl_set *, nb_loops); for (i = 0; i < nb_loops; i++) - domains[i] = NULL; + { + domains[i] = NULL; + doms[i] = NULL; + } ppl_new_C_Polyhedron_from_space_dimension (&ph, scop_nb_params (scop), 0); FOR_EACH_VEC_ELT (loop_p, SESE_LOOP_NEST (region), i, loop) if (!loop_in_sese_p (loop_outer (loop), region)) - build_loop_iteration_domains (scop, loop, ph, 0, domains); + build_loop_iteration_domains (scop, loop, ph, 0, domains, + isl_set_copy (scop->context), doms); FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) - if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]) - ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron - (&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t) - domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]); - else - ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron - (&PBB_DOMAIN (pbb), ph); + { + if (domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]) + ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron + (&PBB_DOMAIN (pbb), (ppl_const_Pointset_Powerset_C_Polyhedron_t) + domains[gbb_loop (PBB_BLACK_BOX (pbb))->num]); + else + ppl_new_Pointset_Powerset_C_Polyhedron_from_C_Polyhedron + (&PBB_DOMAIN (pbb), ph); + + if (doms[gbb_loop (PBB_BLACK_BOX (pbb))->num]) + pbb->domain = isl_set_copy (doms[gbb_loop (PBB_BLACK_BOX (pbb))->num]); + else + pbb->domain = isl_set_copy (scop->context); + } for (i = 0; i < nb_loops; i++) - if (domains[i]) - ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]); + { + if (domains[i]) + ppl_delete_Pointset_Powerset_C_Polyhedron (domains[i]); + + if (doms[i]) + isl_set_free (doms[i]); + } ppl_delete_Polyhedron (ph); free (domains); + + free (doms); } /* Add a constrain to the ACCESSES polyhedron for the alias set of @@ -2461,6 +2511,8 @@ new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb) ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron (&PBB_DOMAIN (pbb1), PBB_DOMAIN (pbb)); + pbb1->domain = isl_set_copy (pbb->domain); + GBB_PBB (gbb1) = pbb1; GBB_CONDITIONS (gbb1) = VEC_copy (gimple, heap, GBB_CONDITIONS (gbb)); GBB_CONDITION_CASES (gbb1) = VEC_copy (gimple, heap, GBB_CONDITION_CASES (gbb));