From patchwork Sun Oct 22 17:39:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 829065 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-464689-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZfSgsA/z"; 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 3yKmyC6MX5z9sRq for ; Mon, 23 Oct 2017 04:39:56 +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=rklXKRQ5ylLtArAVT+QmbGz91SMn95yc2P6Z6c8dU6wC2BoV8V EU8G1zlhi9wbBLNqe7+bdMvZfX1/ZGqkc19lGpaE3s43n2GYIcJowHEBwIKGe45l UiCY2VqCoTGY6aUrlzLgEu0blo9khqgV97k55cxRjPvKKO70KUldrsAVo= 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=wm/zc1wHLZ9mXpfU6tvn2M8O0bQ=; b=ZfSgsA/zIgtYcB4GuLbO AB5a4eLHD+/yUEbexiPegcPVriR4gNUT5po1jSrvldYu+cMOMwnBxEGHSLPYYBJe SgFxd/x/af727I8viHvdXwzAbmcEcy25qi9zGxHudUkWlnuCsT7Zv6dVHhOKmGDK hAo2VTrUTa259QlytPzUBzI= Received: (qmail 3400 invoked by alias); 22 Oct 2017 17:39:39 -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 3355 invoked by uid 89); 22 Oct 2017 17:39:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients 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; Sun, 22 Oct 2017 17:39:35 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 7C7F6127EF; Sun, 22 Oct 2017 19:39:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 797F711DA8; Sun, 22 Oct 2017 19:39:31 +0200 (CEST) Received: from [78.35.155.138] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 59ecd7d3-02b7-7f0000012729-7f000001981b-1 for ; Sun, 22 Oct 2017 19:39:31 +0200 Received: from [192.168.178.20] (xdsl-78-35-155-138.netcologne.de [78.35.155.138]) (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; Sun, 22 Oct 2017 19:39:30 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 56342, matmul was not simplified Message-ID: Date: Sun, 22 Oct 2017 19:39:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Hello world, the attached patch fixes the PR by calling gfc_simplify_expr for parameter arrays, which do not yet appear to simplified completely by the time they reach gfc_simplify_matmul. I suspect this will also fix some more simplification issues, but I didn't search for other cases. Regression-tested. OK for trunk? Regards Thomas 2017-10-22 Thomas Koenig PR fortran/56342 * simplify.c (is_constant_array_expr): If the expression is a parameter array, call gfc_simplify_expr. 2017-10-22 Thomas Koenig PR fortran/56342 * gfortran.dg/matmul_const.f90: New test. Index: simplify.c =================================================================== --- simplify.c (Revision 253768) +++ simplify.c (Arbeitskopie) @@ -227,7 +227,8 @@ } -/* Test that the expression is an constant array. */ +/* Test that the expression is an constant array, simplifying if + we are dealing with a parameter array. */ static bool is_constant_array_expr (gfc_expr *e) @@ -237,6 +238,10 @@ if (e == NULL) return true; + if (e->expr_type == EXPR_VARIABLE && e->rank > 0 + && e->symtree->n.sym->attr.flavor == FL_PARAMETER) + gfc_simplify_expr (e, 1); + if (e->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e)) return false;