From patchwork Thu Jul 25 12:57:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1136885 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-505667-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="SxOW61qS"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="H9aqv8yq"; 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 45vXLp15Mrz9sDQ for ; Thu, 25 Jul 2019 22:57:51 +1000 (AEST) 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=kAE74HKB7F/677+uJ4Ppud7aX3o3bkDI1LPrre036WtxGw3/IS hOClVWzuMwxcuwElVr0nZxOcIuXslRPSmz82ViNTlri01pSRIww3SGFHACUnpyTL 1Iu8eluzuE2QYG5jRzM+pE6gK82tiopwdu3qHhhsNcCZZ8hhSSKL2uVvU= 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=PC5nK+P752WX4T1iuWBIjLwlDKI=; b=SxOW61qSRuHZIGPRR9yD RO575iC4U40vA4JiIgvJpLlpvoETo4IZOcK7a47Aef060AzmzFQk1gOBxzLPAE3h NuWd4tZ0MbzVq7xu5u3WpB7hl+1TUhqu2TrpHH8AJ2EyQoi63oPdF6lSSUs5NwOF 4hq8moIwzepYPVl6iauJtwQ= Received: (qmail 111644 invoked by alias); 25 Jul 2019 12:57:42 -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 111627 invoked by uid 89); 25 Jul 2019 12:57:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*tkoenig, U*tkoenig, Koenig, tkoenig@gcc.gnu.org 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; Thu, 25 Jul 2019 12:57:40 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id C4272134E7; Thu, 25 Jul 2019 14:57:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1564059456; bh=lMFvpOozOlqWJxj4QJv1DzkgnXVPcq9Xl4bokdo6fUI=; h=To:From:Subject:Message-ID:Date:From; b=H9aqv8yqrUlw3JVJeE8JuN8CByOnBBb9fCI5ON5CVbdjScn+aLvLGGABQLW5oCaWH P1aKfLdnEE/fvvmlgcfbxkSSr1KuX622V1JTeiQRG7x6vE9j/yVVb0F8FQ+DH77mg1 MPZvEKlpjJhT3GOs3AJIV1db3cL0YXrUZjCSHEwZAf4LWLLzHtNunUZKuy3ta2gkug SDtW+goG3ODRovBJGsTtDhXD19CpXZghr7YEFnOQ9zDEzjo/RjNTspZZLFr0Fs5dmF H+F4Yesz2lESdwRL9KCXyGaX3JiPU4LVPZ1gBKx6CRqVfh4bV9yuHw/Adf2/qYiUzG 1wO6DIVsgtpfA== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id B569E11EE7; Thu, 25 Jul 2019 14:57:36 +0200 (CEST) Received: from [2001:4dd7:fb2a:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5d39a740-5e31-7f0000012729-7f000001b294-1 for ; Thu, 25 Jul 2019 14:57:36 +0200 Received: from [IPv6:2001:4dd7:fb2a:0:7285:c2ff:fe6c:992d] (2001-4dd7-fb2a-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:fb2a:0:7285:c2ff:fe6c:992d]) (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; Thu, 25 Jul 2019 14:57:35 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Improve dependency checking Message-ID: Date: Thu, 25 Jul 2019 14:57:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Hello world, the attached pach does some more work in gfc_check_dependency for the case where an identity between arguments would also lead to problems. It does not lead to removal of the warning with -Warray-temporaries, because that is still generated by the call to library function. Instead, I checked for the names of the variables which used to be introduced by the matmul inlining code. Regression-tested. OK for trunk? Regards Thomas 2019-07-25 Thomas Koenig PR fortran/65819 * dependency.h (gfc_dep_resovler): Add optional argument identical. * dependency.c (gfc_check_dependency): Do not alway return 1 if the symbol is the same. Pass on identical to gfc_dep_resolver. (gfc_check_element_vs_element): Whitespace fix. (gfc_dep_resolver): Adjust comment for function. If identical is true, return 1 if any overlap has been found. 2019-07-25 Thomas Koenig PR fortran/65819 * gfortran.dg/dependency_54.f90: New test. Index: dependency.c =================================================================== --- dependency.c (Revision 273733) +++ dependency.c (Arbeitskopie) @@ -1351,13 +1351,10 @@ gfc_check_dependency (gfc_expr *expr1, gfc_expr *e return 0; } - if (identical) - return 1; - /* Identical and disjoint ranges return 0, overlapping ranges return 1. */ if (expr1->ref && expr2->ref) - return gfc_dep_resolver (expr1->ref, expr2->ref, NULL); + return gfc_dep_resolver (expr1->ref, expr2->ref, NULL, identical); return 1; @@ -1884,6 +1881,7 @@ gfc_check_element_vs_element (gfc_ref *lref, gfc_r if (i > -2) return GFC_DEP_NODEP; + return GFC_DEP_EQUAL; } @@ -2084,13 +2082,15 @@ ref_same_as_full_array (gfc_ref *full_ref, gfc_ref /* Finds if two array references are overlapping or not. Return value - 2 : array references are overlapping but reversal of one or + 2 : array references are overlapping but reversal of one or more dimensions will clear the dependency. - 1 : array references are overlapping. - 0 : array references are identical or not overlapping. */ + 1 : array references are overlapping, or identical is true and + there is some kind of overlap. + 0 : array references are identical or not overlapping. */ int -gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse) +gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse, + bool identical) { int n; int m; @@ -2124,11 +2124,15 @@ int case REF_ARRAY: + /* For now, treat all coarrays as dangerous. */ + if (lref->u.ar.codimen || rref->u.ar.codimen) + return 1; + if (ref_same_as_full_array (lref, rref)) - return 0; + return identical; if (ref_same_as_full_array (rref, lref)) - return 0; + return identical; if (lref->u.ar.dimen != rref->u.ar.dimen) { @@ -2180,6 +2184,8 @@ int gcc_assert (rref->u.ar.dimen_type[n] == DIMEN_ELEMENT && lref->u.ar.dimen_type[n] == DIMEN_ELEMENT); this_dep = gfc_check_element_vs_element (rref, lref, n); + if (identical && this_dep == GFC_DEP_EQUAL) + this_dep = GFC_DEP_OVERLAP; } /* If any dimension doesn't overlap, we have no dependency. */ @@ -2240,6 +2246,9 @@ int know the worst one.*/ update_fin_dep: + if (identical && this_dep == GFC_DEP_EQUAL) + this_dep = GFC_DEP_OVERLAP; + if (this_dep > fin_dep) fin_dep = this_dep; } @@ -2253,7 +2262,7 @@ int /* Exactly matching and forward overlapping ranges don't cause a dependency. */ - if (fin_dep < GFC_DEP_BACKWARD) + if (fin_dep < GFC_DEP_BACKWARD && !identical) return 0; /* Keep checking. We only have a dependency if @@ -2267,11 +2276,14 @@ int rref = rref->next; } + /* Assume the worst if we nest to different depths. */ + if (lref || rref) + return 1; + /* If we haven't seen any array refs then something went wrong. */ gcc_assert (fin_dep != GFC_DEP_ERROR); - /* Assume the worst if we nest to different depths. */ - if (lref || rref) + if (identical && fin_dep != GFC_DEP_NODEP) return 1; return fin_dep == GFC_DEP_OVERLAP; Index: dependency.h =================================================================== --- dependency.h (Revision 273733) +++ dependency.h (Arbeitskopie) @@ -37,7 +37,7 @@ int gfc_check_fncall_dependency (gfc_expr *, sym_i int gfc_check_dependency (gfc_expr *, gfc_expr *, bool); int gfc_expr_is_one (gfc_expr *, int); -int gfc_dep_resolver(gfc_ref *, gfc_ref *, gfc_reverse *); +int gfc_dep_resolver(gfc_ref *, gfc_ref *, gfc_reverse *, bool identical = false); int gfc_are_equivalenced_arrays (gfc_expr *, gfc_expr *); gfc_expr * gfc_discard_nops (gfc_expr *);