From patchwork Fri Oct 7 14:38:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 118325 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 23E60B70F5 for ; Sat, 8 Oct 2011 01:39:44 +1100 (EST) Received: (qmail 9858 invoked by alias); 7 Oct 2011 14:39:33 -0000 Received: (qmail 9622 invoked by uid 22791); 7 Oct 2011 14:39:30 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp21.services.sfr.fr (HELO smtp21.services.sfr.fr) (93.17.128.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Oct 2011 14:38:32 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2116.sfr.fr (SMTP Server) with ESMTP id E150B7000240; Fri, 7 Oct 2011 16:38:30 +0200 (CEST) Received: from gimli.local (55.123.193.77.rev.sfr.net [77.193.123.55]) by msfrf2116.sfr.fr (SMTP Server) with ESMTP id 6BF5870001A6; Fri, 7 Oct 2011 16:38:30 +0200 (CEST) X-SFR-UUID: 20111007143830442.6BF5870001A6@msfrf2116.sfr.fr MIME-Version: 1.0 From: Mikael Morin To: gfortran , GCC patches Message-ID: <20111007143750.3558.83173@gimli.local> In-Reply-To: <20111007143743.3558.82419@gimli.local> References: <20111007143743.3558.82419@gimli.local> Subject: [Patch, fortran] [01..04/14] Support coarray subreferences: Add subreferences support in gfc_conv_expr_descriptor Date: Fri, 7 Oct 2011 16:38:30 +0200 (CEST) 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 These patches change the descriptor initialization code in gfc_conv_expr_descriptor introduced by the recent scalarizer patchset at http://gcc.gnu.org/ml/fortran/2011-09/msg00056.html. It was supposing (just like the code it was replacing) that coarrays were always full, but a subobject of a coarray is also a coarray (if non-allocatable, non-pointer). Thus, if `a' is a coarray of rank 2; `a', `a(1,:)' and `a(1,2)' are all valid coarrays. Because of the two latter ones, we have to distinguish between the full array rank (2 in the three cases above), and the partial reference rank (respectively 2, 1, 0). As a result: - in patch 4, we use loop.dimen (partial rank) instead of ndim (full rank) for accessing loop and descriptor elements. - in patch 3, we count codimensions from 0 and add to it either ndim or loop.dimen depending on whether we access array ref's elements or loop elements. Patches 1 and 2 are preliminary changes. OK? 2011-10-06 Mikael Morin * trans-array.c (gfc_conv_expr_descriptor): Move ndim initialization earlier. 2011-10-06 Mikael Morin * trans-array.c (gfc_conv_expr_descriptor): Save some horizontal space. 2011-10-06 Mikael Morin PR fortran/50420 * trans-array.c (gfc_conv_expr_descriptor): Count codimensions starting from zero, and add then the relevant offset (either ndim or loop.dimen) depending on context. 2011-10-06 Mikael Morin PR fortran/50420 * trans-array.c (gfc_conv_expr_descriptor): Use loop.dimen instead of ndim for the descriptor's rank. diff --git a/trans-array.c b/trans-array.c index 57534e0..605b356 100644 --- a/trans-array.c +++ b/trans-array.c @@ -6138,13 +6138,13 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) gfc_rank_cst[dim], stride); } - for (n = ndim; n < ndim + codim; n++) + for (n = loop.dimen; n < loop.dimen + codim; n++) { from = loop.from[n]; to = loop.to[n]; gfc_conv_descriptor_lbound_set (&loop.pre, parm, gfc_rank_cst[n], from); - if (n < ndim + codim - 1) + if (n < loop.dimen + codim - 1) gfc_conv_descriptor_ubound_set (&loop.pre, parm, gfc_rank_cst[n], to); }