From patchwork Sat May 9 11:59:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 470309 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CC93D14007F for ; Sat, 9 May 2015 21:59:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=SnKGc6mT; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=vZuElQ9Rb77VZgRM3 E0y/RIpZKh4hvXW1aZrqAkpe1RmZN89nEMJZWeKcADnE5sKWJZf2lAZzD3qo7M9P KfVF+3StrSan8LUK/Pdh1msfB4OGNW7wUMGSdbMWlF70o+KI/PtDr62RgPu3uMP0 tXHjg6wo4RiAZoJZHy7vEBtEsg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=/YvXIBAapp0uLdWseVWC715 v0vw=; b=SnKGc6mTMea63BaMWUKD3yQ8vu/TitKXUkKP2dujEtghXDuR8o9pQLA 3ZqHl3eRX8ebOrGsUjhU0dmsAYLPiPGnvupT9T3xmilnS71BlHYxOWSjx/Dedn6p 01SpQGxIbgBZ9mVTiFHoZlS2cUW52MVvFswLiAzQEAXC881sa3Vk= Received: (qmail 48636 invoked by alias); 9 May 2015 11:59:26 -0000 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 Received: (qmail 48617 invoked by uid 89); 9 May 2015 11:59:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: smtp22.services.sfr.fr Received: from smtp22.services.sfr.fr (HELO smtp22.services.sfr.fr) (93.17.128.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 09 May 2015 11:59:23 +0000 Received: from filter.sfr.fr (localhost [86.72.15.135]) by msfrf2201.sfr.fr (SMTP Server) with ESMTP id 9C87A70000B7; Sat, 9 May 2015 13:59:20 +0200 (CEST) Authentication-Results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header.from=mikael.morin@sfr.fr Received: from tolstoi.localhost (135.15.72.86.rev.sfr.net [86.72.15.135]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by msfrf2201.sfr.fr (SMTP Server) with ESMTP id 84E40700009C; Sat, 9 May 2015 13:59:19 +0200 (CEST) X-SFR-UUID: 20150509115919544.84E40700009C@msfrf2201.sfr.fr Message-ID: <554DF684.2000800@sfr.fr> Date: Sat, 09 May 2015 13:59:00 +0200 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Thomas Koenig , "fortran@gcc.gnu.org" , gcc-patches Subject: Re: [patch, Fortran] Fix PR 66041 References: <554D348A.2050509@netcologne.de> In-Reply-To: <554D348A.2050509@netcologne.de> X-IsSubscribed: yes Hello, Le 09/05/2015 00:11, Thomas Koenig a écrit : > Index: frontend-passes.c > =================================================================== > --- frontend-passes.c (Revision 222864) > +++ frontend-passes.c (Arbeitskopie) > @@ -2611,14 +2611,40 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, > { > /* Look at full individual sections, like a(:). The first index > is the lbound of a full ref. */ > - > + int j; > gfc_array_ref *ar; > + gfc_expr *lbound_e; > > - ar = gfc_find_array_ref (e_in); > + lbound_e = gfc_copy_expr (e_in); > + ar = gfc_find_array_ref (lbound_e); > + > ar->type = AR_FULL; > + for (j = 0; j < ar->dimen; j++) > + { > + gfc_free_expr (ar->start[j]); > + ar->start[j] = NULL; > + gfc_free_expr (ar->end[j]); > + ar->end[j] = NULL; > + gfc_free_expr (ar->stride[j]); > + ar->stride[j] = NULL; > + } > + You also need to remove/free the trailing subreferences. > + /* We have to get rid of the shape, if thre is one. Do > + so by freeing it and calling gfc_resolve to rebuild it, > + if necessary. */ > + > + if (lbound_e->shape) > + gfc_free_shape (&(lbound_e->shape), lbound_e->rank); > + > + lbound_e->rank = ar->dimen; ar->dimen is not what you think it is. It is 3 for array(1, 1, :), while the rank is 1. gfc_resolve_expr should set the rank for you, so just remove this line. > + > + gfc_resolve_expr (lbound_e); > + lbound = get_array_inq_function (GFC_ISYM_LBOUND, > + lbound_e, i + 1); free lbound_e? > } > - lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in, > - i_index + 1); > + else > + lbound = get_array_inq_function (GFC_ISYM_LBOUND, e_in, > + i_index + 1); You can't reuse e_in if it has subreferences. One suggestion: you may want to move all the above to a function extracting the full array. > } > > ar->dimen_type[i] = DIMEN_ELEMENT; > @@ -2639,6 +2665,8 @@ scalarized_expr (gfc_expr *e_in, gfc_expr **index, > i_index ++; > } > } > + gfc_free_expr (e_in); > + This side effect is asking for trouble. Instead of this, remove the copies made in the callers. This is independant from the rest, so it can be made later as a follow-up. > return e; > } > > I attach a variant of your inline_matmul_8.f90 that is not working yet because of subreferences. Mikael --- inline_matmul_8.f90.old 2015-05-09 13:31:28.420790646 +0200 +++ inline_matmul_8.f90 2015-05-09 13:42:50.741799982 +0200 @@ -3,15 +3,22 @@ ! PR 66041 - this used to ICE with an incomplete fix for the PR. program main implicit none - real, dimension(1,-2:0) :: a1 + type :: t + real :: c + end type t + type(t), dimension(1,-2:0) :: a1 real, dimension(3,2) :: b1 real, dimension(2) :: c1 + real, dimension(1,2) :: c2 - data a1 /17., -23., 29./ + data a1%c /17., -23., 29./ data b1 / 2., -3., 5., -7., 11., -13./ - c1 = matmul(a1(1,:), b1) + c1 = matmul(a1(1,:)%c, b1) if (any (c1-[248., -749.] /= 0.)) call abort + + c2 = matmul(a1%c, b1) + if (any (c2-reshape([248., -749.],shape(c2)) /= 0.)) call abort end program main ! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "original" } }