From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20058 invoked by alias); 27 Oct 2011 23:35:26 -0000 Received: (qmail 29555 invoked by uid 22791); 27 Oct 2011 23:33:00 -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:32:44 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id 8357870000AC; Fri, 28 Oct 2011 01:32:43 +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 2B3F67000089; Fri, 28 Oct 2011 01:32:43 +0200 (CEST) X-SFR-UUID: 20111027233243177.2B3F67000089@msfrf2512.sfr.fr Content-Type: multipart/mixed; boundary="===============4196910069579780000==" MIME-Version: 1.0 From: Mikael Morin To: gfortran , GCC patches Message-ID: <20111027233243.18581.83954@gimli.local> In-Reply-To: <20111027233144.18581.30688@gimli.local> References: <20111027232818.18581.901@gimli.local> <20111027233144.18581.30688@gimli.local> Subject: [Patch, fortran] [47..48/66] inline sum and product: Update the scalarizer: New gfc_loopinfo::nested_loop field. Date: Thu, 27 Oct 2011 23:35: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/msg02553.txt.bz2 --===============4196910069579780000== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-length: 182 This introduces the nested_loop list of nested loops inside a gfc_loopinfo struct (patch 47). Patch 48 adds to the scalarizer functions self-recursive calls on the nested loops. OK? --===============4196910069579780000== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-47.CL" Content-length: 213 2011-10-19 Mikael Morin * trans.h (struct gfc_loopinfo): New fields nested and next. * trans-array.c (gfc_add_ss_to_loop): Update list of nested list if ss has non-null nested_ss field. --===============4196910069579780000== Content-Type: text/x-diff; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-47.patch" Content-length: 1368 diff --git a/trans-array.c b/trans-array.c index 1a86ae6..0c1dc89 100644 --- a/trans-array.c +++ b/trans-array.c @@ -645,6 +645,7 @@ void gfc_add_ss_to_loop (gfc_loopinfo * loop, gfc_ss * head) { gfc_ss *ss; + gfc_loopinfo *nested_loop; if (head == gfc_ss_terminator) return; @@ -654,6 +655,21 @@ gfc_add_ss_to_loop (gfc_loopinfo * loop, gfc_ss * head) ss = head; for (; ss && ss != gfc_ss_terminator; ss = ss->next) { + if (ss->nested_ss) + { + nested_loop = ss->nested_ss->loop; + + /* More than one ss can belong to the same loop. Hence, we add the + loop to the chain only if it is different from the previously + added one, to avoid duplicate nested loops. */ + if (nested_loop != loop->nested) + { + gcc_assert (nested_loop->next == NULL); + nested_loop->next = loop->nested; + loop->nested = nested_loop; + } + } + if (ss->next == gfc_ss_terminator) ss->loop_chain = loop->ss; else diff --git a/trans.h b/trans.h index 0608879..0549aa7 100644 --- a/trans.h +++ b/trans.h @@ -279,6 +279,9 @@ typedef struct gfc_loopinfo /* The SS describing the temporary used in an assignment. */ gfc_ss *temp_ss; + /* Chain of nested loops. */ + struct gfc_loopinfo *nested, *next; + /* The scalarization loop index variables. */ tree loopvar[GFC_MAX_DIMENSIONS]; --===============4196910069579780000== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-48.CL" Content-length: 404 2011-10-19 Mikael Morin * trans-array.c (gfc_add_loop_ss_code): Skip non-nestedmost ss. Call recursively gfc_add_loop_ss_code for all the nested loops. (gfc_conv_ss_startstride): Only get the descriptor for the outermost ss. Call recursively gfc_conv_ss_startstride for all the nested loops. (set_loop_bounds): Call recursively for all the nested loops. (set_delta): Ditto. --===============4196910069579780000== Content-Type: text/x-diff; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-48.patch" Content-length: 2875 diff --git a/trans-array.c b/trans-array.c index 0c1dc89..27356a1 100644 --- a/trans-array.c +++ b/trans-array.c @@ -2295,10 +2295,12 @@ static void gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, locus * where) { + gfc_loopinfo *nested_loop; gfc_se se; gfc_ss_info *ss_info; gfc_array_info *info; gfc_expr *expr; + bool skip_nested = false; int n; /* TODO: This can generate bad code if there are ordering dependencies, @@ -2309,6 +2311,10 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, { gcc_assert (ss); + /* Cross loop arrays are handled from within the most nested loop. */ + if (ss->nested_ss != NULL) + continue; + ss_info = ss->info; expr = ss_info->expr; info = &ss_info->data.array; @@ -2355,7 +2361,12 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, /* Add the expressions for scalar and vector subscripts. */ for (n = 0; n < GFC_MAX_DIMENSIONS; n++) if (info->subscript[n]) - gfc_add_loop_ss_code (loop, info->subscript[n], true, where); + { + gfc_add_loop_ss_code (loop, info->subscript[n], true, where); + /* The recursive call will have taken care of the nested loops. + No need to do it twice. */ + skip_nested = true; + } set_vector_loop_bounds (ss); break; @@ -2410,6 +2421,11 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, bool subscript, gcc_unreachable (); } } + + if (!skip_nested) + for (nested_loop = loop->nested; nested_loop; + nested_loop = nested_loop->next) + gfc_add_loop_ss_code (nested_loop, nested_loop->ss, subscript, where); } @@ -3495,8 +3511,10 @@ done: switch (ss_info->type) { case GFC_SS_SECTION: - /* Get the descriptor for the array. */ - gfc_conv_ss_descriptor (&loop->pre, ss, !loop->array_parameter); + /* Get the descriptor for the array. If it is a cross loops array, + we got the descriptor already in the outermost loop. */ + if (ss->parent == NULL) + gfc_conv_ss_descriptor (&loop->pre, ss, !loop->array_parameter); for (n = 0; n < ss->dimen; n++) gfc_conv_section_startstride (loop, ss, ss->dim[n]); @@ -3785,6 +3803,9 @@ done: tmp = gfc_finish_block (&block); gfc_add_expr_to_block (&loop->pre, tmp); } + + for (loop = loop->nested; loop; loop = loop->next) + gfc_conv_ss_startstride (loop); } /* Return true if both symbols could refer to the same data object. Does @@ -4246,6 +4267,9 @@ set_loop_bounds (gfc_loopinfo *loop) } } mpz_clear (i); + + for (loop = loop->nested; loop; loop = loop->next) + set_loop_bounds (loop); } @@ -4356,6 +4380,9 @@ set_delta (gfc_loopinfo *loop) } } } + + for (loop = loop->nested; loop; loop = loop->next) + set_delta (loop); } --===============4196910069579780000==--