From patchwork Tue Jan 8 23:11:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1022221 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-493677-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="O8s1C8B1"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="TT3hGjmW"; 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 43Z7LB33Hjz9sLw for ; Wed, 9 Jan 2019 10:11:29 +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=qthEDiApMoXqRfvrg2wao23KQBxLOf82pmBcCF8bI+kQqjjhn9 j0YAtogi+dHvclWU3IebD1G0SE6PEO4Ze4oZw/bVAEhrKiSzmyBGAXJCI7N/TOfl nghcYqc0MXRlUl4ok1yc5wUrgvu1SikmY4yNh6QfJasmYpJKa0NwFt1sc= 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=AtiYUj8OOcaihm9vVjfW8liwxMc=; b=O8s1C8B1IMq8HlXjfjRc nwHFGRcB5jhMrE8ef60LhOYQjnMRuXKnXvP752Ig8WILqDgwF1Wu6PwfSAWuvxOx rqYTv2Ck2gsU9aLcarD8s5ZKTVVgYTxriXioYwn+fx4BLn3oHljp4CrzFlODNy+8 kjCTj95PbDJ6QmLIvxF3nec= Received: (qmail 106795 invoked by alias); 8 Jan 2019 23:11:19 -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 106777 invoked by uid 89); 8 Jan 2019 23:11:18 -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=2019-01-09, 20190109 X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Jan 2019 23:11:16 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id A848F13384; Wed, 9 Jan 2019 00:11:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1546989073; bh=RNHMgaj8T24OqkDsAMcBgrBb8d2zmcNljtl7qa3Uzxg=; h=To:From:Subject:Message-ID:Date:From; b=TT3hGjmW3NQ0ixS8ivfBoP0yxOR8ISg+Bhtgc4lWV7b3PvrG/f4ofkkH376slCaB3 pZYkNsUtIFfQqI1Mm1deBLkYA+SXHuhqRhj4LJMlC81dQzH8E88lP21nDOcHtYHvJL X2RWsQyErL1cM0Il9Bqn3dynygZcjpeKwudUb9KVOFgu6uGaFvDjiF/kmaWoXrYk9i a6dgcmzq93s+hKVlUv+TInrryxbbCgr1FhUO3n64QNBeJ7ZETt6L5kie5olTL+jyP6 bnDdoqUlI+EsmvxLuHadWB6cv+qDw98sCphAmsoM79hUOx71Q6gGTk03ZGiTz+fze8 eiNBXuWxd2vwA== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id A55F011ED8; Wed, 9 Jan 2019 00:11:13 +0100 (CET) Received: from [78.35.135.87] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5c352e11-0bea-7f0000012729-7f000001b902-1 for ; Wed, 09 Jan 2019 00:11:13 +0100 Received: from [192.168.178.68] (xdsl-78-35-135-87.nc.de [78.35.135.87]) (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; Wed, 9 Jan 2019 00:11:12 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 68426, simplification of SPREAD Message-ID: <12d02ff7-b6ca-cfca-3fce-ef3b13bcfda5@netcologne.de> Date: Wed, 9 Jan 2019 00:11:12 +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 the PR by simpliy having gfc_simplify_spread also do its job when there's an EXPR_STRUCTURE. The code to correctly handle that case was already in place, it just was not run for that case. Regression-tested. OK for trunk? Regards Thomas ! { dg-do run } ! PR 68426 - simplification used to fail. module m implicit none type t integer :: i end type t type(t), dimension(2), parameter :: a1 = (/ t(1), t(2) /) type(t), dimension(1), parameter :: c = spread ( a1(1), 1, 1 ) end module m ig25@flaemmli:~/Krempel/Spread> cat ChangeLog 2019-01-09 Thomas Koenig PR fortran/68426 * simplify.c (gfc_simplify_spread): Also simplify if the type of source is an EXPR_STRUCTURE. 2019-01-09 Thomas Koenig PR fortran/68426 * gfortran.dg/spread_simplify_1.f90: New test. Index: simplify.c =================================================================== --- simplify.c (Revision 267737) +++ simplify.c (Arbeitskopie) @@ -7572,7 +7572,8 @@ gfc_simplify_spread (gfc_expr *source, gfc_expr *d return NULL; } - if (source->expr_type == EXPR_CONSTANT) + if (source->expr_type == EXPR_CONSTANT + || source->expr_type == EXPR_STRUCTURE) { gcc_assert (dim == 0);