From patchwork Fri Jan 21 19:27:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 79912 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 B00B4B710C for ; Sat, 22 Jan 2011 06:32:33 +1100 (EST) Received: (qmail 19757 invoked by alias); 21 Jan 2011 19:31:06 -0000 Received: (qmail 19199 invoked by uid 22791); 21 Jan 2011 19:30:59 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_GB, TW_SV, 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; Fri, 21 Jan 2011 19:30:37 +0000 Received: by yxd5 with SMTP id 5so674334yxd.20 for ; Fri, 21 Jan 2011 11:30:35 -0800 (PST) Received: by 10.147.32.2 with SMTP id k2mr1364556yaj.37.1295638234297; Fri, 21 Jan 2011 11:30:34 -0800 (PST) Received: from napoca ([76.233.39.4]) by mx.google.com with ESMTPS id b27sm11850781ana.28.2011.01.21.11.30.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 21 Jan 2011 11:30:33 -0800 (PST) Received: by napoca (sSMTP sendmail emulation); Fri, 21 Jan 2011 13:30:30 -0600 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de Subject: [PATCH 26/28] Pass to dr_analyze_indices the analysis loop for subscripts. Date: Fri, 21 Jan 2011 13:27:45 -0600 Message-Id: <1295638067-13460-27-git-send-email-sebpop@gmail.com> In-Reply-To: References: 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 From: spop 2011-01-19 Sebastian Pop * graphite-scop-detection.c (stmt_has_simple_data_refs_p): Update call to graphite_find_data_references_in_stmt. * graphite-sese-to-poly.c (outermost_loop_in_sese_1): New. (try_generate_gimple_bb): Call outermost_loop_in_sese_1. Update call to graphite_find_data_references_in_stmt. (analyze_drs_in_stmts): Same. * tree-data-ref.c (dr_analyze_indices): Pass in parameter the loop in which the scalar analysis of indices is performed. (create_data_ref): Same. Update call to dr_analyze_indices. (find_data_references_in_stmt): Update call to create_data_ref. (graphite_find_data_references_in_stmt): Same. * tree-data-ref.h (graphite_find_data_references_in_stmt): Update declaration. (create_data_ref): Same. * tree-ssa-loop-prefetch.c (determine_loop_nest_reuse): Update call to create_data_ref. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@169045 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 19 +++++++++++++ gcc/ChangeLog.graphite | 19 +++++++++++++ gcc/graphite-scop-detection.c | 4 ++- gcc/graphite-sese-to-poly.c | 60 ++++++++++++++++++++++++++++++++++++----- gcc/tree-data-ref.c | 31 +++++++++++--------- gcc/tree-data-ref.h | 4 +- gcc/tree-ssa-loop-prefetch.c | 3 +- 7 files changed, 115 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3cdbd3b..29eb4c5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,24 @@ 2011-01-21 Sebastian Pop + * graphite-scop-detection.c (stmt_has_simple_data_refs_p): Update + call to graphite_find_data_references_in_stmt. + * graphite-sese-to-poly.c (outermost_loop_in_sese_1): New. + (try_generate_gimple_bb): Call outermost_loop_in_sese_1. Update + call to graphite_find_data_references_in_stmt. + (analyze_drs_in_stmts): Same. + * tree-data-ref.c (dr_analyze_indices): Pass in parameter the loop + in which the scalar analysis of indices is performed. + (create_data_ref): Same. Update call to dr_analyze_indices. + (find_data_references_in_stmt): Update call to create_data_ref. + (graphite_find_data_references_in_stmt): Same. + * tree-data-ref.h (graphite_find_data_references_in_stmt): Update + declaration. + (create_data_ref): Same. + * tree-ssa-loop-prefetch.c (determine_loop_nest_reuse): Update + call to create_data_ref. + +2011-01-21 Sebastian Pop + * graphite-sese-to-poly.c (build_poly_scop): Move rewrite_commutative_reductions_out_of_ssa before find_scop_parameters. diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index c611368..12524d4 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,24 @@ 2011-01-19 Sebastian Pop + * graphite-scop-detection.c (stmt_has_simple_data_refs_p): Update + call to graphite_find_data_references_in_stmt. + * graphite-sese-to-poly.c (outermost_loop_in_sese_1): New. + (try_generate_gimple_bb): Call outermost_loop_in_sese_1. Update + call to graphite_find_data_references_in_stmt. + (analyze_drs_in_stmts): Same. + * tree-data-ref.c (dr_analyze_indices): Pass in parameter the loop + in which the scalar analysis of indices is performed. + (create_data_ref): Same. Update call to dr_analyze_indices. + (find_data_references_in_stmt): Update call to create_data_ref. + (graphite_find_data_references_in_stmt): Same. + * tree-data-ref.h (graphite_find_data_references_in_stmt): Update + declaration. + (create_data_ref): Same. + * tree-ssa-loop-prefetch.c (determine_loop_nest_reuse): Update + call to create_data_ref. + +2011-01-19 Sebastian Pop + * graphite-sese-to-poly.c (build_poly_scop): Move rewrite_commutative_reductions_out_of_ssa before find_scop_parameters. diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 693dfeb..45c6c75 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -263,7 +263,9 @@ stmt_has_simple_data_refs_p (loop_p outermost_loop, gimple stmt) bool res = true; VEC (data_reference_p, heap) *drs = VEC_alloc (data_reference_p, heap, 5); - graphite_find_data_references_in_stmt (outermost_loop, stmt, &drs); + graphite_find_data_references_in_stmt (outermost_loop, + loop_containing_stmt (stmt), + stmt, &drs); FOR_EACH_VEC_ELT (data_reference_p, drs, j, dr) for (i = 0; i < DR_NUM_DIMENSIONS (dr); i++) diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 3f419c8..88536fe 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -241,6 +241,32 @@ free_scops (VEC (scop_p, heap) *scops) VEC_free (scop_p, heap, scops); } +/* Same as outermost_loop_in_sese, returns the outermost loop + containing BB in REGION, but makes sure that the returned loop + belongs to the REGION, and so this returns the first loop in the + REGION when the loop containing BB does not belong to REGION. */ + +static loop_p +outermost_loop_in_sese_1 (sese region, basic_block bb) +{ + loop_p nest = outermost_loop_in_sese (region, bb); + + if (loop_in_sese_p (nest, region)) + return nest; + + /* When the basic block BB does not belong to a loop in the region, + return the first loop in the region. */ + nest = nest->inner; + while (nest) + if (loop_in_sese_p (nest, region)) + break; + else + nest = nest->next; + + gcc_assert (nest); + return nest; +} + /* Generates a polyhedral black box only if the bb contains interesting information. */ @@ -248,14 +274,23 @@ static gimple_bb_p try_generate_gimple_bb (scop_p scop, basic_block bb) { VEC (data_reference_p, heap) *drs = VEC_alloc (data_reference_p, heap, 5); - loop_p nest = outermost_loop_in_sese (SCOP_REGION (scop), bb); + sese region = SCOP_REGION (scop); + loop_p nest = outermost_loop_in_sese_1 (region, bb); gimple_stmt_iterator gsi; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); - if (!is_gimple_debug (stmt)) - graphite_find_data_references_in_stmt (nest, stmt, &drs); + loop_p loop; + + if (is_gimple_debug (stmt)) + continue; + + loop = loop_containing_stmt (stmt); + if (!loop_in_sese_p (loop, region)) + loop = nest; + + graphite_find_data_references_in_stmt (nest, loop, stmt, &drs); } return new_gimple_bb (bb, drs); @@ -2019,17 +2054,28 @@ analyze_drs_in_stmts (scop_p scop, basic_block bb, VEC (gimple, heap) *stmts) gimple_bb_p gbb; gimple stmt; int i; + sese region = SCOP_REGION (scop); - if (!bb_in_sese_p (bb, SCOP_REGION (scop))) + if (!bb_in_sese_p (bb, region)) return; - nest = outermost_loop_in_sese (SCOP_REGION (scop), bb); + nest = outermost_loop_in_sese_1 (region, bb); gbb = gbb_from_bb (bb); FOR_EACH_VEC_ELT (gimple, stmts, i, stmt) - if (!is_gimple_debug (stmt)) - graphite_find_data_references_in_stmt (nest, stmt, + { + loop_p loop; + + if (is_gimple_debug (stmt)) + continue; + + loop = loop_containing_stmt (stmt); + if (!loop_in_sese_p (loop, region)) + loop = nest; + + graphite_find_data_references_in_stmt (nest, loop, stmt, &GBB_DATA_REFS (gbb)); + } } /* Insert STMT at the end of the STMTS sequence and then insert the diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index ccc0091..5aecbff 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -820,13 +820,11 @@ dr_analyze_innermost (struct data_reference *dr) } /* Determines the base object and the list of indices of memory reference - DR, analyzed in loop nest NEST. */ + DR, analyzed in LOOP and instantiated in loop nest NEST. */ static void -dr_analyze_indices (struct data_reference *dr, struct loop *nest) +dr_analyze_indices (struct data_reference *dr, loop_p nest, loop_p loop) { - gimple stmt = DR_STMT (dr); - struct loop *loop = loop_containing_stmt (stmt); VEC (tree, heap) *access_fns = NULL; tree ref = unshare_expr (DR_REF (dr)), aref = ref, op; tree base, off, access_fn = NULL_TREE; @@ -935,11 +933,13 @@ free_data_ref (data_reference_p dr) /* Analyzes memory reference MEMREF accessed in STMT. The reference is read if IS_READ is true, write otherwise. Returns the - data_reference description of MEMREF. NEST is the outermost loop of the - loop nest in that the reference should be analyzed. */ + data_reference description of MEMREF. NEST is the outermost loop + in which the reference should be instantiated, LOOP is the loop in + which the data reference should be analyzed. */ struct data_reference * -create_data_ref (struct loop *nest, tree memref, gimple stmt, bool is_read) +create_data_ref (loop_p nest, loop_p loop, tree memref, gimple stmt, + bool is_read) { struct data_reference *dr; @@ -956,7 +956,7 @@ create_data_ref (struct loop *nest, tree memref, gimple stmt, bool is_read) DR_IS_READ (dr) = is_read; dr_analyze_innermost (dr); - dr_analyze_indices (dr, nest); + dr_analyze_indices (dr, nest, loop); dr_analyze_alias (dr); if (dump_file && (dump_flags & TDF_DETAILS)) @@ -4079,7 +4079,8 @@ find_data_references_in_stmt (struct loop *nest, gimple stmt, FOR_EACH_VEC_ELT (data_ref_loc, references, i, ref) { - dr = create_data_ref (nest, *ref->pos, stmt, ref->is_read); + dr = create_data_ref (nest, loop_containing_stmt (stmt), + *ref->pos, stmt, ref->is_read); gcc_assert (dr != NULL); /* FIXME -- data dependence analysis does not work correctly for objects @@ -4100,12 +4101,14 @@ find_data_references_in_stmt (struct loop *nest, gimple stmt, return ret; } -/* Stores the data references in STMT to DATAREFS. If there is an unanalyzable - reference, returns false, otherwise returns true. NEST is the outermost - loop of the loop nest in which the references should be analyzed. */ +/* Stores the data references in STMT to DATAREFS. If there is an + unanalyzable reference, returns false, otherwise returns true. + NEST is the outermost loop of the loop nest in which the references + should be instantiated, LOOP is the loop in which the references + should be analyzed. */ bool -graphite_find_data_references_in_stmt (struct loop *nest, gimple stmt, +graphite_find_data_references_in_stmt (loop_p nest, loop_p loop, gimple stmt, VEC (data_reference_p, heap) **datarefs) { unsigned i; @@ -4122,7 +4125,7 @@ graphite_find_data_references_in_stmt (struct loop *nest, gimple stmt, FOR_EACH_VEC_ELT (data_ref_loc, references, i, ref) { - dr = create_data_ref (nest, *ref->pos, stmt, ref->is_read); + dr = create_data_ref (nest, loop, *ref->pos, stmt, ref->is_read); gcc_assert (dr != NULL); VEC_safe_push (data_reference_p, heap, *datarefs, dr); } diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index bcf8c02..2e7e0e5 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -407,9 +407,9 @@ extern void free_data_ref (data_reference_p); extern void free_data_refs (VEC (data_reference_p, heap) *); extern bool find_data_references_in_stmt (struct loop *, gimple, VEC (data_reference_p, heap) **); -extern bool graphite_find_data_references_in_stmt (struct loop *, gimple, +extern bool graphite_find_data_references_in_stmt (loop_p, loop_p, gimple, VEC (data_reference_p, heap) **); -struct data_reference *create_data_ref (struct loop *, tree, gimple, bool); +struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple, bool); extern bool find_loop_nest (struct loop *, VEC (loop_p, heap) **); extern void compute_all_dependences (VEC (data_reference_p, heap) *, VEC (ddr_p, heap) **, VEC (loop_p, heap) *, diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c index 59c65d3..d920ec6 100644 --- a/gcc/tree-ssa-loop-prefetch.c +++ b/gcc/tree-ssa-loop-prefetch.c @@ -1562,7 +1562,8 @@ determine_loop_nest_reuse (struct loop *loop, struct mem_ref_group *refs, for (gr = refs; gr; gr = gr->next) for (ref = gr->refs; ref; ref = ref->next) { - dr = create_data_ref (nest, ref->mem, ref->stmt, !ref->write_p); + dr = create_data_ref (nest, loop_containing_stmt (ref->stmt), + ref->mem, ref->stmt, !ref->write_p); if (dr) {