From patchwork Mon Aug 15 07:12:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 110007 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 1E85BB6F70 for ; Mon, 15 Aug 2011 17:16:11 +1000 (EST) Received: (qmail 14584 invoked by alias); 15 Aug 2011 07:14:40 -0000 Received: (qmail 14398 invoked by uid 22791); 15 Aug 2011 07:14:38 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Aug 2011 07:14:22 +0000 Received: by gxk3 with SMTP id 3so329074gxk.20 for ; Mon, 15 Aug 2011 00:14:22 -0700 (PDT) Received: by 10.91.109.20 with SMTP id l20mr1433302agm.105.1313392462181; Mon, 15 Aug 2011 00:14:22 -0700 (PDT) Received: from napoca (adsl-99-184-92-236.dsl.austtx.sbcglobal.net [99.184.92.236]) by mx.google.com with ESMTPS id k20sm4926906and.31.2011.08.15.00.14.20 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Aug 2011 00:14:21 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Mon, 15 Aug 2011 02:14:19 -0500 From: Sebastian Pop To: skimo@kotnet.org, tobias@grosser.es Cc: gcc-patches@gcc.gnu.org, Sebastian Pop Subject: [PATCH 20/20] disable loop flattening Date: Mon, 15 Aug 2011 02:12:59 -0500 Message-Id: <1313392379-1525-20-git-send-email-sebpop@gmail.com> In-Reply-To: <1313392379-1525-1-git-send-email-sebpop@gmail.com> References: <1313392379-1525-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 --- gcc/graphite-flattening.c | 289 +-------------------------------------------- 1 files changed, 4 insertions(+), 285 deletions(-) diff --git a/gcc/graphite-flattening.c b/gcc/graphite-flattening.c index c58d8a3..c8c8531 100644 --- a/gcc/graphite-flattening.c +++ b/gcc/graphite-flattening.c @@ -145,297 +145,16 @@ along with GCC; see the file COPYING3. If not see At each step, the iteration domain of the outer loop is enlarged to contain enough points to iterate over the inner loop domain. */ -/* Initializes RES to the number of iterations of the linearized loop - LST. RES is the cardinal of the iteration domain of LST. */ - -static void -lst_linearized_niter (lst_p lst, mpz_t res) -{ - int i; - lst_p l; - mpz_t n; - - mpz_init (n); - mpz_set_si (res, 0); - - FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) - if (LST_LOOP_P (l)) - { - lst_linearized_niter (l, n); - mpz_add (res, res, n); - } - - if (LST_LOOP_P (lst)) - { - lst_niter_for_loop (lst, n); - - if (mpz_cmp_si (res, 0) != 0) - mpz_mul (res, res, n); - else - mpz_set (res, n); - } - - mpz_clear (n); -} - -/* Applies the translation "f (x) = x + OFFSET" to the loop containing - STMT. */ - -static void -lst_offset (lst_p stmt, mpz_t offset) -{ - lst_p inner = LST_LOOP_FATHER (stmt); - poly_bb_p pbb = LST_PBB (stmt); - ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb); - int inner_depth = lst_depth (inner); - ppl_dimension_type inner_dim = psct_dynamic_dim (pbb, inner_depth); - ppl_Linear_Expression_t expr; - ppl_dimension_type dim; - ppl_Coefficient_t one; - mpz_t x; - - mpz_init (x); - mpz_set_si (x, 1); - ppl_new_Coefficient (&one); - ppl_assign_Coefficient_from_mpz_t (one, x); - - ppl_Polyhedron_space_dimension (poly, &dim); - ppl_new_Linear_Expression_with_dimension (&expr, dim); - - ppl_set_coef (expr, inner_dim, 1); - ppl_set_inhomogeneous_gmp (expr, offset); - ppl_Polyhedron_affine_image (poly, inner_dim, expr, one); - ppl_delete_Linear_Expression (expr); - ppl_delete_Coefficient (one); -} - -/* Scale by FACTOR the loop LST containing STMT. */ - -static void -lst_scale (lst_p lst, lst_p stmt, mpz_t factor) -{ - mpz_t x; - ppl_Coefficient_t one; - int outer_depth = lst_depth (lst); - poly_bb_p pbb = LST_PBB (stmt); - ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb); - ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth); - ppl_Linear_Expression_t expr; - ppl_dimension_type dim; - - mpz_init (x); - mpz_set_si (x, 1); - ppl_new_Coefficient (&one); - ppl_assign_Coefficient_from_mpz_t (one, x); - - ppl_Polyhedron_space_dimension (poly, &dim); - ppl_new_Linear_Expression_with_dimension (&expr, dim); - - /* outer_dim = factor * outer_dim. */ - ppl_set_coef_gmp (expr, outer_dim, factor); - ppl_Polyhedron_affine_image (poly, outer_dim, expr, one); - ppl_delete_Linear_Expression (expr); - - mpz_clear (x); - ppl_delete_Coefficient (one); -} - -/* Project the INNER loop into the iteration domain of the OUTER loop. - STRIDE is the number of iterations between two iterations of the - outer loop. */ - -static void -lst_project_loop (lst_p outer, lst_p inner, mpz_t stride) -{ - int i; - lst_p stmt; - mpz_t x; - ppl_Coefficient_t one; - int outer_depth = lst_depth (outer); - int inner_depth = lst_depth (inner); - - mpz_init (x); - mpz_set_si (x, 1); - ppl_new_Coefficient (&one); - ppl_assign_Coefficient_from_mpz_t (one, x); - - FOR_EACH_VEC_ELT (lst_p, LST_SEQ (inner), i, stmt) - { - poly_bb_p pbb = LST_PBB (stmt); - ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb); - ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth); - ppl_dimension_type inner_dim = psct_dynamic_dim (pbb, inner_depth); - ppl_Linear_Expression_t expr; - ppl_dimension_type dim; - ppl_dimension_type *ds; - - /* There should be no loops under INNER. */ - gcc_assert (!LST_LOOP_P (stmt)); - ppl_Polyhedron_space_dimension (poly, &dim); - ppl_new_Linear_Expression_with_dimension (&expr, dim); - - /* outer_dim = outer_dim * stride + inner_dim. */ - ppl_set_coef (expr, inner_dim, 1); - ppl_set_coef_gmp (expr, outer_dim, stride); - ppl_Polyhedron_affine_image (poly, outer_dim, expr, one); - ppl_delete_Linear_Expression (expr); - - /* Project on inner_dim. */ - ppl_new_Linear_Expression_with_dimension (&expr, dim - 1); - ppl_Polyhedron_affine_image (poly, inner_dim, expr, one); - ppl_delete_Linear_Expression (expr); - - /* Remove inner loop and the static schedule of its body. */ - ds = XNEWVEC (ppl_dimension_type, 2); - ds[0] = inner_dim; - ds[1] = inner_dim + 1; - ppl_Polyhedron_remove_space_dimensions (poly, ds, 2); - PBB_NB_SCATTERING_TRANSFORM (pbb) -= 2; - free (ds); - } - - mpz_clear (x); - ppl_delete_Coefficient (one); -} - -/* Flattens the loop nest LST. Return true when something changed. - OFFSET is used to compute the number of iterations of the outermost - loop before the current LST is executed. */ - -static bool -lst_flatten_loop (lst_p lst, mpz_t init_offset) -{ - int i; - lst_p l; - bool res = false; - mpz_t n, one, offset, stride; - - mpz_init (n); - mpz_init (one); - mpz_init (offset); - mpz_init (stride); - mpz_set (offset, init_offset); - mpz_set_si (one, 1); - - lst_linearized_niter (lst, stride); - lst_niter_for_loop (lst, n); - mpz_tdiv_q (stride, stride, n); - - FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) - if (LST_LOOP_P (l)) - { - res = true; - - lst_flatten_loop (l, offset); - lst_niter_for_loop (l, n); - - lst_project_loop (lst, l, stride); - - /* The offset is the number of iterations minus 1, as we want - to execute the next statements at the same iteration as the - last iteration of the loop. */ - mpz_sub (n, n, one); - mpz_add (offset, offset, n); - } - else - { - lst_scale (lst, l, stride); - if (mpz_cmp_si (offset, 0) != 0) - lst_offset (l, offset); - } - - FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) - if (LST_LOOP_P (l)) - lst_remove_loop_and_inline_stmts_in_loop_father (l); - - mpz_clear (n); - mpz_clear (one); - mpz_clear (offset); - mpz_clear (stride); - return res; -} - -/* Remove all but the first 3 dimensions of the scattering: - - dim0: the static schedule for the loop - - dim1: the dynamic schedule of the loop - - dim2: the static schedule for the loop body. */ - -static void -remove_unused_scattering_dimensions (lst_p lst) -{ - int i; - lst_p stmt; - mpz_t x; - ppl_Coefficient_t one; - - mpz_init (x); - mpz_set_si (x, 1); - ppl_new_Coefficient (&one); - ppl_assign_Coefficient_from_mpz_t (one, x); - - FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, stmt) - { - poly_bb_p pbb = LST_PBB (stmt); - ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb); - int j, nb_dims_to_remove = PBB_NB_SCATTERING_TRANSFORM (pbb) - 3; - ppl_dimension_type *ds; - - /* There should be no loops inside LST after flattening. */ - gcc_assert (!LST_LOOP_P (stmt)); - - if (!nb_dims_to_remove) - continue; - - ds = XNEWVEC (ppl_dimension_type, nb_dims_to_remove); - for (j = 0; j < nb_dims_to_remove; j++) - ds[j] = j + 3; - - ppl_Polyhedron_remove_space_dimensions (poly, ds, nb_dims_to_remove); - PBB_NB_SCATTERING_TRANSFORM (pbb) -= nb_dims_to_remove; - free (ds); - } - - mpz_clear (x); - ppl_delete_Coefficient (one); -} - -/* Flattens all the loop nests of LST. Return true when something - changed. */ - -static bool -lst_do_flatten (lst_p lst) -{ - int i; - lst_p l; - bool res = false; - mpz_t zero; - - if (!lst - || !LST_LOOP_P (lst)) - return false; - - mpz_init (zero); - mpz_set_si (zero, 0); - - FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l) - if (LST_LOOP_P (l)) - { - res |= lst_flatten_loop (l, zero); - remove_unused_scattering_dimensions (l); - } - - lst_update_scattering (lst); - mpz_clear (zero); - return res; -} /* Flatten all the loop nests in SCOP. Returns true when something changed. */ bool -flatten_all_loops (scop_p scop) +flatten_all_loops (scop_p scop ATTRIBUTE_UNUSED) { - return lst_do_flatten (SCOP_TRANSFORMED_SCHEDULE (scop)); + /* FIXME: This pass is disabled until it is translated to use + isl_map_flatten_range. */ + return false; } #endif