From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25721 invoked by alias); 22 Jun 2011 12:33:19 -0000 Received: (qmail 25701 invoked by uid 22791); 22 Jun 2011 12:33:18 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL,BAYES_00,TW_TM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Jun 2011 12:33:00 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 1906A8765C; Wed, 22 Jun 2011 14:32:58 +0200 (CEST) Date: Wed, 22 Jun 2011 13:05:00 -0000 From: Michael Matz To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: Re: [PATCH] Middle-end arrays, forward-ported to trunk (again) In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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-06/txt/msg01662.txt.bz2 Hi, On Tue, 21 Jun 2011, Richard Guenther wrote: > I failed to see where the scalarizer inserts the temporary vars it > creates into the scope blocks (thus the gimplify.c hunk ...). Any help > here is welcome. The scoping of the scalarizer is a bit funny. gfc_start_scalarized_body sets up scopes for all dimensions and leaves with the 'body' scope open. The bound expressions are inserted (for your testcase) into the 'block' scope. In between there are the loop->code[n] scopes. You can't decide to not go into gfc_start_scalarized_body early, because lse.expr will only be set later, so you have to properly finish_block all these in-between blocks and wire them into loop.pre and then block, like gfc_trans_scalarizing_loops would do. Of course you don't want to actually generate loops, which gfc_trans_scalarizing_loops does. So you have to manually unwind the blocks. If you do that, then you also don't need the ??? marked gfc_add_block_to_block (&block, &loop.pre). So, the code in the VLA_VIEW_EXPR case should be roughly this: else if (TREE_CODE (lse.expr) == VLA_VIEW_EXPR) { int dim; stmtblock_t *pblock; pblock = &body; for (dim = 0; dim < loop.dimen + loop.codimen; dim++) { n = loop.order[dim]; tmp = gfc_finish_block (pblock); gfc_add_expr_to_block (&loop.code[n], tmp); loop.loopvar[n] = NULL_TREE; pblock = &loop.code[n]; } tmp = gfc_finish_block (pblock); gfc_add_expr_to_block (&loop.pre, tmp); gfc_add_block_to_block (&block, &loop.pre); gfc_add_block_to_block (&block, &loop.post); gfc_cleanup_loop (&loop); } Sorry, no real patch, my quilt queue is busted somehow. Ciao, Michael.