From patchwork Sat Jan 12 21:09:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1023996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493943-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Tu8wpyb1"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="L55HMA5G"; dkim-atps=neutral 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 43cXRX0NJqz9s3q for ; Sun, 13 Jan 2019 08:09:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=FQBxcAujoCKnLEjomY+SZBPreIOkgoV6EdEutMQNq4GaI8lStv KKlo0tWGCpwfvkVbLpyEMwTL275hMWUytcoV1fcDhXOIi9C86LQAfzmV2/rh1sGr qFiOWndJdKhooQGrYdUxROgn9eBtERqidnN6dckn/pfTi81M89fLYvZz8= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=UBeozNcEGQjy2/HVoJuZF6d0oSY=; b=Tu8wpyb1QYioXlNhxRgU AAfXQl+fZw6PQah3Nbf/EAJNfMOfKP09HkrRglo5rKzAjbWixxK3Tdx8OBRvLcVD txTw/M0bM59gnsIyOahaetpr4/dG6yp8QfjH4kZaOJ7PFmd3tQmWhfEVCnUDUTPr oJTdnTM7wy6g7g68aPVs5Jg= Received: (qmail 111113 invoked by alias); 12 Jan 2019 21:09:21 -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 111045 invoked by uid 89); 12 Jan 2019 21:09:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=packing, 267829, shape, Convert X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Jan 2019 21:09:18 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id AF25512662; Sat, 12 Jan 2019 22:09:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1547327355; bh=7iHFhNiGxJosE/zPiFnQXVgTsmKgqCLiqL4PQko5Hxo=; h=To:From:Subject:Message-ID:Date:From; b=L55HMA5G3zSD44CcCWqbmltxHQVCRUNh5aIulh6a0HMeeBrSCxGLxgKX43uHbB0k3 yCcTYYLgTr5AvG6mfOyA3PUDRQPzBMwoWPDaQiASWxMSfOvhsxbW6wFLrwVX2/juCH asg7x1kMv7CVRBzBdGXpDRhDNsdnUI6THMtxIF0L+omrln0YKOJ4Tu8q2aysJeMtEH L/1ijNx7wap9td1eVZ3TtMSMGYfUpPZaBKu+0r3bOHLH/VlCMO/NXnuagIxuXNMidc 49suLUz+aq75nkhwrJsleTnVEU2Moht6a4D6FoHd+rraFjEYbzw+ZQNBGNmcVX/7d4 Rhnco4AxZZEqQ== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id A163D11EA3; Sat, 12 Jan 2019 22:09:15 +0100 (CET) Received: from [78.35.146.213] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c3a577b-5f8a-7f0000012729-7f0000019f04-1 for ; Sat, 12 Jan 2019 22:09:15 +0100 Received: from [192.168.178.68] (xdsl-78-35-146-213.nc.de [78.35.146.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Sat, 12 Jan 2019 22:09:14 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix the rest of PR 59345 Message-ID: Date: Sat, 12 Jan 2019 22:09:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Hello world, this patch fixes the rest of the PR by making sure we do not pack/unpack for function results which are either allocatable or explicit shape arrays. Regression-tested. OK for trunk? Regards Thomas 2019-01-12 Thomas Koenig PR fortran/59345 * trans-array.c (gfc_conv_array_parameter): Remove TODO. Do not pack/unpack results of functions which return an explicit-shaped or allocatable array. 2019-01-12 Thomas Koenig PR fortran/59345 * gfortran.dg/internal_pack_17.f90: New test. * gfortran.dg/alloc_comp_auto_array_3.f90: Adjust number of calls to builtin_free. Index: trans-array.c =================================================================== --- trans-array.c (Revision 267829) +++ trans-array.c (Arbeitskopie) @@ -7740,7 +7740,6 @@ array_parameter_size (tree desc, gfc_expr *expr, t } /* Convert an array for passing as an actual parameter. */ -/* TODO: Optimize passing g77 arrays. */ void gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77, @@ -7866,11 +7865,23 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * no_pack = contiguous && no_pack; - /* If we have an expression, an array temporary will be - generated which does not need to be packed / unpacked - if passed to an explicit-shape dummy array. */ + /* If we have an EXPR_OP or a function returning an explicit-shaped + or allocatable array, an array temporary will be generated which + does not need to be packed / unpacked if passed to an + explicit-shape dummy array. */ - no_pack = no_pack || (g77 && expr->expr_type == EXPR_OP); + if (g77) + { + if (expr->expr_type == EXPR_OP) + no_pack = 1; + else if (expr->expr_type == EXPR_FUNCTION && expr->value.function.esym) + { + gfc_symbol *result = expr->value.function.esym->result; + if (result->attr.dimension + && (result->as->type == AS_EXPLICIT || result->attr.allocatable)) + no_pack = 1; + } + } /* Array constructors are always contiguous and do not need packing. */ array_constructor = g77 && !this_array_result && expr->expr_type == EXPR_ARRAY;