From patchwork Sun Jan 10 11:55:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 565349 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 9FCF21402A1 for ; Sun, 10 Jan 2016 22:55:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=KWLB5iOv; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=SgNI9vdll2Hebrjw861XRYtK+J5CfiqXmXlWLSfu0LPkjkux3p QqH3Wj7pFvYS4EEP2CmAmG1EMJ0bkYFAgucZxWDIvGU5lHr8CqOedRXFClRNrrCp R7s85ONP59h/1/Wz+0qdc2/+EnsGUdq+J7iCg7iILkSC7/YhiY7zklwB8= 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=/MiY2UE6JlB/PQudKd+Rsij4R+E=; b=KWLB5iOvgWOqezrXXvxr MlBclyjwxawFHwMqlyb2AA1RNYprZAadEcCCtw+I5/CTrLfypz3r3h197IF9S1L1 qOk0muum1tfvjKY5PdhUj6CDdJT0AIeiaWHqgFQNC/GscOiT00asOmBkDLy4Y6ZU Rcmudnp4ccQTC4t7oBKXQwQ= Received: (qmail 125933 invoked by alias); 10 Jan 2016 11:55:22 -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 125913 invoked by uid 89); 10 Jan 2016 11:55:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_20, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=expr2, expr_type, exec_call, EXEC_CALL X-Spam-User: qpsmtpd, 2 recipients 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 10 Jan 2016 11:55:19 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id 821EE12785; Sun, 10 Jan 2016 12:55:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id 7446911E13; Sun, 10 Jan 2016 12:55:14 +0100 (CET) Received: from [78.35.172.147] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.0.9) (envelope-from ) id 569246a2-0b98-7f0000012729-7f00000184e4-1 for ; Sun, 10 Jan 2016 12:55:14 +0100 Received: from [192.168.178.20] (xdsl-78-35-172-147.netcologne.de [78.35.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Sun, 10 Jan 2016 12:55:12 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 69154, inline matmul with WHERE Message-ID: <5692469F.8090906@netcologne.de> Date: Sun, 10 Jan 2016 12:55:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 Hello world, the attached patch fixes the regression. Before this, front-end optimization would have tried to put a DO loop inside a WHERE construct, leading to an ICE. Regression-tested. OK for trunk? Thomas 2016-01-10 Thomas Koenig PR fortran/69154 * frontend-passes.c (in_where): New variable. (inline_matmul_assign): Don't try this if we are within a WHERE statement. (gfc_code_walker): Keep track of in_where. Index: frontend-passes.c =================================================================== --- frontend-passes.c (revision 232196) +++ frontend-passes.c (working copy) @@ -78,6 +78,10 @@ static int forall_level; static bool in_omp_workshare; +/* Keep track of whether we are within a WHERE statement. */ + +static bool in_where; + /* Keep track of iterators for array constructors. */ static int iterator_level; @@ -2790,6 +2794,9 @@ inline_matmul_assign (gfc_code **c, int *walk_subt if (co->op != EXEC_ASSIGN) return 0; + if (in_where) + return 0; + expr1 = co->expr1; expr2 = co->expr2; if (expr2->expr_type != EXPR_FUNCTION @@ -3268,6 +3275,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code gfc_code *co; gfc_association_list *alist; bool saved_in_omp_workshare; + bool saved_in_where; /* There might be statement insertions before the current code, which must not affect the expression walker. */ @@ -3274,6 +3282,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code co = *c; saved_in_omp_workshare = in_omp_workshare; + saved_in_where = in_where; switch (co->op) { @@ -3301,6 +3310,10 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code WALK_SUBEXPR (co->ext.iterator->step); break; + case EXEC_WHERE: + in_where = true; + break; + case EXEC_CALL: case EXEC_ASSIGN_CALL: for (a = co->ext.actual; a; a = a->next) @@ -3554,6 +3567,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code doloop_level --; in_omp_workshare = saved_in_omp_workshare; + in_where = saved_in_where; } } return 0;