From patchwork Thu Jul 21 18:31:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 106131 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 D35E5B6F71 for ; Fri, 22 Jul 2011 04:31:57 +1000 (EST) Received: (qmail 20126 invoked by alias); 21 Jul 2011 18:31:44 -0000 Received: (qmail 20087 invoked by uid 22791); 21 Jul 2011 18:31:40 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yx0-f175.google.com (HELO mail-yx0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jul 2011 18:31:23 +0000 Received: by yxi19 with SMTP id 19so891661yxi.20 for ; Thu, 21 Jul 2011 11:31:23 -0700 (PDT) Received: by 10.236.195.72 with SMTP id o48mr22562yhn.432.1311273082967; Thu, 21 Jul 2011 11:31: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 j2sm1366199yhe.47.2011.07.21.11.31.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jul 2011 11:31:22 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Thu, 21 Jul 2011 13:31:20 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, tobias@grosser.es, Sebastian Pop Subject: [PATCH 02/10] Do not compute twice type, lb, and ub. Date: Thu, 21 Jul 2011 13:31:02 -0500 Message-Id: <1311273070-12128-3-git-send-email-sebpop@gmail.com> In-Reply-To: <1311273070-12128-1-git-send-email-sebpop@gmail.com> References: <1311273070-12128-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 2011-07-05 Sebastian Pop * graphite-clast-to-gimple.c (graphite_create_new_loop): Do not recompute type, lb, and ub. Get them from... (graphite_create_new_loop_guard): ...here. Pass in parameter pointers to type, lb, and ub. (translate_clast_for_loop): Update function calls. (translate_clast_for): Same. --- gcc/ChangeLog | 9 ++++++ gcc/graphite-clast-to-gimple.c | 61 +++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5c1c630..13a8bd8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2011-07-05 Sebastian Pop + * graphite-clast-to-gimple.c (graphite_create_new_loop): Do not + recompute type, lb, and ub. Get them from... + (graphite_create_new_loop_guard): ...here. Pass in parameter + pointers to type, lb, and ub. + (translate_clast_for_loop): Update function calls. + (translate_clast_for): Same. + +2011-07-05 Sebastian Pop + * graphite-clast-to-gimple.c (compute_bounds_for_level): Call psct_dynamic_dim. (translate_clast_for_loop): Pass loop level to dependency_in_loop_p. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 53af18e..a8ac9c6 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -696,23 +696,15 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level, becomes the child loop of the OUTER_LOOP. NEWIVS_INDEX binds CLooG's scattering name to the induction variable created for the loop of STMT. The new induction variable is inserted in the NEWIVS - vector. */ + vector and is of type TYPE. */ static struct loop * -graphite_create_new_loop (sese region, edge entry_edge, +graphite_create_new_loop (edge entry_edge, struct clast_for *stmt, loop_p outer, VEC (tree, heap) **newivs, - htab_t newivs_index, htab_t params_index, int level) + htab_t newivs_index, + tree type, tree lb, tree ub) { - tree lb_type = gcc_type_for_clast_expr (stmt->LB, region, *newivs, - newivs_index, params_index); - tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, *newivs, - newivs_index, params_index); - tree type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type); - tree lb = clast_to_gcc_expression (type, stmt->LB, region, *newivs, - newivs_index, params_index); - tree ub = clast_to_gcc_expression (type, stmt->UB, region, *newivs, - newivs_index, params_index); tree stride = gmp_cst_to_tree (type, stmt->stride); tree ivvar = create_tmp_var (type, "graphite_IV"); tree iv, iv_after_increment; @@ -887,7 +879,8 @@ static edge graphite_create_new_loop_guard (sese region, edge entry_edge, struct clast_for *stmt, VEC (tree, heap) *newivs, - htab_t newivs_index, htab_t params_index) + htab_t newivs_index, htab_t params_index, + int level, tree *type, tree *lb, tree *ub) { tree cond_expr; edge exit_edge; @@ -895,28 +888,30 @@ graphite_create_new_loop_guard (sese region, edge entry_edge, newivs_index, params_index); tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, newivs, newivs_index, params_index); - tree type = max_precision_type (lb_type, ub_type); - tree lb = clast_to_gcc_expression (type, stmt->LB, region, newivs, - newivs_index, params_index); - tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs, - newivs_index, params_index); + + *type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type); + *lb = clast_to_gcc_expression (*type, stmt->LB, region, newivs, + newivs_index, params_index); + *ub = clast_to_gcc_expression (*type, stmt->UB, region, newivs, + newivs_index, params_index); + /* When ub is simply a constant or a parameter, use lb <= ub. */ - if (TREE_CODE (ub) == INTEGER_CST || TREE_CODE (ub) == SSA_NAME) - cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub); + if (TREE_CODE (*ub) == INTEGER_CST || TREE_CODE (*ub) == SSA_NAME) + cond_expr = fold_build2 (LE_EXPR, boolean_type_node, *lb, *ub); else { - tree one = (POINTER_TYPE_P (type) + tree one = (POINTER_TYPE_P (*type) ? size_one_node - : fold_convert (type, integer_one_node)); + : fold_convert (*type, integer_one_node)); /* Adding +1 and using LT_EXPR helps with loop latches that have a loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes 2^k-1 due to integer overflow, and the condition lb <= ub is true, even if we do not want this. However lb < ub + 1 is false, as expected. */ - tree ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR - : PLUS_EXPR, type, ub, one); + tree ub_one = fold_build2 (POINTER_TYPE_P (*type) ? POINTER_PLUS_EXPR + : PLUS_EXPR, *type, *ub, one); - cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one); + cond_expr = fold_build2 (LT_EXPR, boolean_type_node, *lb, ub_one); } exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr); @@ -935,17 +930,19 @@ translate_clast (sese, loop_p, struct clast_stmt *, edge, - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. - PARAMS_INDEX connects the cloog parameters with the gimple parameters in the sese region. */ + static edge translate_clast_for_loop (sese region, loop_p context_loop, struct clast_for *stmt, edge next_e, VEC (tree, heap) **newivs, htab_t newivs_index, htab_t bb_pbb_mapping, - int level, htab_t params_index) + int level, htab_t params_index, tree type, + tree lb, tree ub) { - struct loop *loop = graphite_create_new_loop (region, next_e, stmt, + struct loop *loop = graphite_create_new_loop (next_e, stmt, context_loop, newivs, - newivs_index, params_index, - level); + newivs_index, + type, lb, ub); edge last_e = single_exit (loop); edge to_body = single_succ_edge (loop->header); basic_block after = to_body->dest; @@ -982,13 +979,15 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt, htab_t newivs_index, htab_t bb_pbb_mapping, int level, htab_t params_index) { + tree type, lb, ub; edge last_e = graphite_create_new_loop_guard (region, next_e, stmt, *newivs, - newivs_index, params_index); + newivs_index, params_index, + level, &type, &lb, &ub); edge true_e = get_true_edge_from_guard_bb (next_e->dest); translate_clast_for_loop (region, context_loop, stmt, true_e, newivs, newivs_index, bb_pbb_mapping, level, - params_index); + params_index, type, lb, ub); return last_e; }