From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29272 invoked by alias); 27 Oct 2011 23:32:57 -0000 Received: (qmail 24163 invoked by uid 22791); 27 Oct 2011 23:32:11 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp25.services.sfr.fr (HELO smtp25.services.sfr.fr) (93.17.128.120) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 23:31:53 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id 2527A7000044; Fri, 28 Oct 2011 01:31:52 +0200 (CEST) Received: from gimli.local (145.15.72.86.rev.sfr.net [86.72.15.145]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id CE66070000AC; Fri, 28 Oct 2011 01:31:51 +0200 (CEST) X-SFR-UUID: 20111027233151845.CE66070000AC@msfrf2512.sfr.fr Content-Type: multipart/mixed; boundary="===============8674831989041628832==" MIME-Version: 1.0 From: Mikael Morin To: gfortran , GCC patches Message-ID: <20111027233151.18581.91359@gimli.local> In-Reply-To: <20111027233144.18581.30688@gimli.local> References: <20111027232818.18581.901@gimli.local> <20111027233144.18581.30688@gimli.local> Subject: [Patch, fortran] [31/66] inline sum and product: Update the scalarizer: Split gfc_conv_loop_setup. Date: Thu, 27 Oct 2011 23:34:00 -0000 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg02543.txt.bz2 --===============8674831989041628832== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-length: 557 Loop-centered functions will be called recursively to handle nested loops. This is the case of gfc_conv_loop_setup. However, gfc_conv_loop_setup has a tempoary handling part in the middle which doesn't need to be called recursively. This patch moves the beginning and ending of gfc_conv_loop_setup into functions of their own, so that they can be called recursively (later). To share gfc_conv_loop_setup's loopspec local variable in the three functions, we store it into gfc_loopinfo's specloop field (which existed, but was completely unused before). OK? --===============8674831989041628832== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-31.CL" Content-length: 423 2011-10-19 Mikael Morin * trans-array.c (set_loop_bounds): Separate the beginning of gfc_conv_loop_setup into a function of its own. (set_delta): Separate the end of gfc_conv_loop_setup into a function of its own. (gfc_conv_loop_setup): Call set_loop_bounds and set delta. (set_loop_bounds, set_delta, gfc_conv_loop_setup): Make loopspec a pointer to the specloop field from the loop struct. --===============8674831989041628832== Content-Type: text/x-diff; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-31.patch" Content-length: 2875 diff --git a/trans-array.c b/trans-array.c index 045c426..302f937 100644 --- a/trans-array.c +++ b/trans-array.c @@ -3919,25 +3919,25 @@ temporary: } -/* Initialize the scalarization loop. Creates the loop variables. Determines - the range of the loop variables. Creates a temporary if required. - Calculates how to transform from loop variables to array indices for each - expression. Also generates code for scalar expressions which have been - moved outside the loop. */ +/* Browse through each array's information from the scalarizer and set the loop + bounds according to the "best" one (per dimension), i.e. the one which + provides the most information (constant bounds, shape, etc). */ -void -gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where) +static void +set_loop_bounds (gfc_loopinfo *loop) { int n, dim, spec_dim; gfc_array_info *info; gfc_array_info *specinfo; - gfc_ss *ss, *tmp_ss; + gfc_ss *ss; tree tmp; - gfc_ss *loopspec[GFC_MAX_DIMENSIONS]; + gfc_ss **loopspec; bool dynamic[GFC_MAX_DIMENSIONS]; mpz_t *cshape; mpz_t i; + loopspec = loop->specloop; + mpz_init (i); for (n = 0; n < loop->dimen; n++) { @@ -4119,6 +4119,26 @@ gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where) loop->from[n] = gfc_index_zero_node; } } + mpz_clear (i); +} + + +static void set_delta (gfc_loopinfo *loop); + + +/* Initialize the scalarization loop. Creates the loop variables. Determines + the range of the loop variables. Creates a temporary if required. + Also generates code for scalar expressions which have been + moved outside the loop. */ + +void +gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where) +{ + gfc_ss *tmp_ss; + tree tmp; + int n; + + set_loop_bounds (loop); /* Add all the scalar code that can be taken out of the loops. This may include calculating the loop bounds, so do it before @@ -4153,15 +4173,31 @@ gfc_conv_loop_setup (gfc_loopinfo * loop, locus * where) } for (n = 0; n < loop->temp_dim; n++) - loopspec[loop->order[n]] = NULL; - - mpz_clear (i); + loop->specloop[loop->order[n]] = NULL; /* For array parameters we don't have loop variables, so don't calculate the translations. */ if (loop->array_parameter) return; + set_delta (loop); +} + + +/* Calculates how to transform from loop variables to array indices for each + array: once loop bounds are chosen, sets the difference (DELTA field) between + loop bounds and array reference bounds, for each array info. */ + +static void +set_delta (gfc_loopinfo *loop) +{ + gfc_ss *ss, **loopspec; + gfc_array_info *info; + tree tmp; + int n, dim; + + loopspec = loop->specloop; + /* Calculate the translation from loop variables to array indices. */ for (ss = loop->ss; ss != gfc_ss_terminator; ss = ss->loop_chain) { --===============8674831989041628832==--