From patchwork Thu Jan 10 20:17:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1023200 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-493803-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="nRbx5ZA0"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="XODpFLnS"; 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 43bHP04DY2z9sCr for ; Fri, 11 Jan 2019 07:17:54 +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=OeMxOkHHqMUXSq6JQDwbzF+lVsqMq/TTXNltDigv37PNw5zD+r VezKEFuERQ/0z1OnPoairN1LDNwzbSTRKr/21Q+pv068X1iRacuns+RNASvH2T/j MJW6wZAni7EJPlqvmKFXPobD3VUCHjiEL3tT8Hfy+t+Es2m8YSmUkGPhQ= 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=8h5saHv9SAVJD077KFfRWZYLHn4=; b=nRbx5ZA0g3YzMzaBBf+v E0NcaxAXQcAYlHjyHwDCctZU/O012oVhfkDq84I1ePLew357C+JRDFApa2g1w1yB UMh+jK0fE74bKm3HxqkvwK9hhd7X11P/9m50lDC0DhRbwPGDPuigmQgyAkHAnlpO 7ZfV2zBw656c8tWPmSUVlHg= Received: (qmail 125669 invoked by alias); 10 Jan 2019 20:17:44 -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 125643 invoked by uid 89); 10 Jan 2019 20:17:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=packing, Temporary, sk:regress, arrays X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Jan 2019 20:17:41 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 1F70412777; Thu, 10 Jan 2019 21:17:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1547151459; bh=2uCkuIfZcWWp/dxiU4jOuml4Ici7RrKD7lWd+oVzmG0=; h=To:From:Subject:Message-ID:Date:From; b=XODpFLnSHDAmEuclOZLT7DR81OF/xTDhklVNhAktQYrMPteyRjy0d48V166rod1uh e2jiIhTasTUFzNjoiW2oVnnyKV/8jC1qTI9awx6AROFAHdTP+BETfknU6/uO2+whWq BevbwgCJzcvFwDyLPxVr7CJFfnMznhTycDSNUUEXjkq1g0OfpTsaaOCALpftzUXtAN Wehnnx+bOQ2EUUiWdCHpoY+/HcNA2O1eaQBvTMhazUiAud2w38xWLT60xYHcYXzdiw JxzEmdrHaUr47Wn3zNU2PwgA65K7lL4rPOCbqCRtTxC3kcIWNFLKcXlxHPDCGoHCqr XClVqkQoCCNjQ== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 19E9A11E73; Thu, 10 Jan 2019 21:17:39 +0100 (CET) Received: from [78.35.146.213] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c37a863-0bea-7f0000012729-7f00000199f0-1 for ; Thu, 10 Jan 2019 21:17:39 +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-smtpin3.netcologne.de (Postfix) with ESMTPSA; Thu, 10 Jan 2019 21:17:37 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [Patch, fortran] Fix PR59345, repacking of a packed temporary array Message-ID: <0f159bf9-42ab-5692-d6f5-dcb8c789410d@netcologne.de> Date: Thu, 10 Jan 2019 21:17:37 +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, the attached patch fixes a rather bad missed optimization, where the generated temporary array for SUBROUTINE S1(A) REAL :: A(3) CALL S2(-A) END SUBROUTINE was packed and unpacked(!). Regression-tested. OK for trunk? Regards Thomas 2019-01-10 Thomas Koenig PR fortran/59345 * trans-array.c (gfc_conv_parameter_array): Temporary arrays generated for expressions do not need to be repacked. 2019-01-10 Thomas Koenig PR fortran/59345 * gfortran.dg/internal_pack_16.f90: New test. Index: trans-array.c =================================================================== --- trans-array.c (Revision 267737) +++ trans-array.c (Arbeitskopie) @@ -7866,6 +7866,12 @@ 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. */ + + no_pack = no_pack || (g77 && expr->expr_type == EXPR_OP); + /* Array constructors are always contiguous and do not need packing. */ array_constructor = g77 && !this_array_result && expr->expr_type == EXPR_ARRAY;