From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by sourceware.org (Postfix) with ESMTPS id 5D74A3858D3C for ; Tue, 30 Nov 2021 20:51:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D74A3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orange.fr Received: from [192.168.1.17] ([92.167.144.168]) by smtp.orange.fr with ESMTPA id sA6MmeBGXS9NTsA6TmtgeJ; Tue, 30 Nov 2021 21:51:54 +0100 X-ME-Helo: [192.168.1.17] X-ME-Auth: MDU4MTIxYWM4YWI0ZGE4ZTUwZWZmNTExZmI2ZWZlMThkM2ZhYiE5OWRkOGM= X-ME-Date: Tue, 30 Nov 2021 21:51:54 +0100 X-ME-IP: 92.167.144.168 Message-ID: Date: Tue, 30 Nov 2021 21:51:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH, fortran] Improve expansion of constant array expressions within constructors Content-Language: en-US To: Harald Anlauf , fortran , gcc-patches References: From: Mikael Morin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 20:51:56 -0000 Hello, On 27/11/2021 21:56, Harald Anlauf via Fortran wrote: > diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c > index 6552eaf3b0c..fbc66097c80 100644 > --- a/gcc/fortran/array.c > +++ b/gcc/fortran/array.c > @@ -1804,6 +1804,12 @@ expand_constructor (gfc_constructor_base base) > if (empty_constructor) > empty_ts = e->ts; > > + /* Simplify constant array expression/section within constructor. */ > + if (e->expr_type == EXPR_VARIABLE && e->rank > 0 && e->ref > + && e->symtree && e->symtree->n.sym > + && e->symtree->n.sym->attr.flavor == FL_PARAMETER) > + gfc_simplify_expr (e, 0); > + > if (e->expr_type == EXPR_ARRAY) > { > if (!expand_constructor (e->value.constructor)) There is another simplification call just a few lines below, that I thought could just be moved up. But it works on a copy of the expression, and managing the copy makes it complex as well, so let’s do it your way. OK.