From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5139 invoked by alias); 27 Oct 2011 23:28:51 -0000 Received: (qmail 5085 invoked by uid 22791); 27 Oct 2011 23:28:50 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,TW_TM 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:28:31 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2512.sfr.fr (SMTP Server) with ESMTP id E32A27000040; Fri, 28 Oct 2011 01:28:29 +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 8B187700008E; Fri, 28 Oct 2011 01:28:29 +0200 (CEST) X-SFR-UUID: 20111027232829569.8B187700008E@msfrf2512.sfr.fr Content-Type: multipart/mixed; boundary="===============3309039602905479285==" MIME-Version: 1.0 From: Mikael Morin To: gfortran , GCC patches Message-ID: <20111027232829.18581.89158@gimli.local> In-Reply-To: <20111027232818.18581.901@gimli.local> References: <20111027232818.18581.901@gimli.local> Subject: [Patch, fortran] [01..06/66] inline sum and product: Prepare gfc_trans_preloop_setup Date: Thu, 27 Oct 2011 23:36: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/msg02568.txt.bz2 --===============3309039602905479285== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-length: 207 This is a 6 steps program to update gfc_trans_preloop_setup. gfc_trans_preloop_setup appeared completely rewritten. These step by step patches show that it is not the case. Combined patch attached here. OK? --===============3309039602905479285== Content-Type: text/x-diff; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr43829-1..6.diff" Content-length: 5595 diff --git a/trans-array.c b/trans-array.c index 3472804e4c6344e68d15af2feee627429ca61018..f615e4e6a10d59b6878033876f7b170f516e651b 100644 *** a/trans-array.c --- b/trans-array.c *************** gfc_conv_array_ref (gfc_se * se, gfc_arr *** 2830,2835 **** --- 2830,2863 ---- } + /* Add the offset corresponding to array's ARRAY_DIM dimension and loop's + LOOP_DIM dimension (if any) to array's offset. */ + + static void + add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss, + gfc_array_ref *ar, int array_dim, int loop_dim) + { + gfc_se se; + gfc_ss_info *info; + tree stride, index; + + info = &ss->data.info; + + gfc_init_se (&se, NULL); + se.loop = loop; + se.expr = info->descriptor; + stride = gfc_conv_array_stride (info->descriptor, array_dim); + index = gfc_conv_array_index_offset (&se, info, array_dim, loop_dim, ar, + stride); + gfc_add_block_to_block (pblock, &se.pre); + + info->offset = fold_build2_loc (input_location, PLUS_EXPR, + gfc_array_index_type, + info->offset, index); + info->offset = gfc_evaluate_now (info->offset, pblock); + } + + /* Generate the code to be executed immediately before entering a scalarization loop. */ *************** static void *** 2837,2847 **** gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, stmtblock_t * pblock) { - tree index; tree stride; gfc_ss_info *info; gfc_ss *ss; ! gfc_se se; int i; /* This code will be executed before entering the scalarization loop --- 2865,2874 ---- gfc_trans_preloop_setup (gfc_loopinfo * loop, int dim, int flag, stmtblock_t * pblock) { tree stride; gfc_ss_info *info; gfc_ss *ss; ! gfc_array_ref *ar; int i; /* This code will be executed before entering the scalarization loop *************** gfc_trans_preloop_setup (gfc_loopinfo * *** 2860,2933 **** if (dim >= info->dimen) continue; - if (dim == info->dimen - 1) - { - /* For the outermost loop calculate the offset due to any - elemental dimensions. It will have been initialized with the - base offset of the array. */ if (info->ref) ! { ! for (i = 0; i < info->ref->u.ar.dimen; i++) ! { ! if (info->ref->u.ar.dimen_type[i] != DIMEN_ELEMENT) ! continue; ! gfc_init_se (&se, NULL); ! se.loop = loop; ! se.expr = info->descriptor; ! stride = gfc_conv_array_stride (info->descriptor, i); ! index = gfc_conv_array_index_offset (&se, info, i, -1, ! &info->ref->u.ar, ! stride); ! gfc_add_block_to_block (pblock, &se.pre); ! info->offset = fold_build2_loc (input_location, PLUS_EXPR, ! gfc_array_index_type, ! info->offset, index); ! info->offset = gfc_evaluate_now (info->offset, pblock); ! } ! } ! i = loop->order[0]; ! /* For the time being, the innermost loop is unconditionally on ! the first dimension of the scalarization loop. */ ! gcc_assert (i == 0); stride = gfc_conv_array_stride (info->descriptor, info->dim[i]); /* Calculate the stride of the innermost loop. Hopefully this will allow the backend optimizers to do their stuff more effectively. */ info->stride0 = gfc_evaluate_now (stride, pblock); - } - else - { - /* Add the offset for the previous loop dimension. */ - gfc_array_ref *ar; if (info->ref) { ! ar = &info->ref->u.ar; ! i = loop->order[dim + 1]; ! } ! else { ! ar = NULL; ! i = dim + 1; ! } ! gfc_init_se (&se, NULL); ! se.loop = loop; ! se.expr = info->descriptor; ! stride = gfc_conv_array_stride (info->descriptor, info->dim[i]); ! index = gfc_conv_array_index_offset (&se, info, info->dim[i], i, ! ar, stride); ! gfc_add_block_to_block (pblock, &se.pre); ! info->offset = fold_build2_loc (input_location, PLUS_EXPR, ! gfc_array_index_type, info->offset, ! index); ! info->offset = gfc_evaluate_now (info->offset, pblock); } /* Remember this offset for the second loop. */ if (dim == loop->temp_dim - 1) --- 2887,2934 ---- if (dim >= info->dimen) continue; + gcc_assert (info->dimen == loop->dimen); if (info->ref) ! ar = &info->ref->u.ar; ! else ! ar = NULL; ! if (dim == loop->dimen - 1) ! i = 0; ! else ! i = dim + 1; ! /* For the time being, there is no loop reordering. */ ! gcc_assert (i == loop->order[i]); ! i = loop->order[i]; ! if (dim == loop->dimen - 1) ! { stride = gfc_conv_array_stride (info->descriptor, info->dim[i]); /* Calculate the stride of the innermost loop. Hopefully this will allow the backend optimizers to do their stuff more effectively. */ info->stride0 = gfc_evaluate_now (stride, pblock); + /* For the outermost loop calculate the offset due to any + elemental dimensions. It will have been initialized with the + base offset of the array. */ if (info->ref) { ! for (i = 0; i < ar->dimen; i++) { ! if (ar->dimen_type[i] != DIMEN_ELEMENT) ! continue; ! add_array_offset (pblock, loop, ss, ar, i, /* unused */ -1); } + } + } + else + /* Add the offset for the previous loop dimension. */ + add_array_offset (pblock, loop, ss, ar, info->dim[i], i); /* Remember this offset for the second loop. */ if (dim == loop->temp_dim - 1) --===============3309039602905479285==--