From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 089A138708FB; Tue, 9 Feb 2021 11:52:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 089A138708FB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: 7+bK5S3BWMicbHSHbuL7fNoZLSQRZ/4oqV953hH8X7s9I5Nuvr1SCrtUs5aygCefQC2k6p096v z5QNo7Ek8R9UXV7Y7ojp2sCCgzM3kxv+DJYjbwcXIiuCQf/Q2k3Zu3mzdO3hVRQ18QJagj4sn1 M8GdItO6WTbB4QkUnKmiiIF9fwhPE9c5aut4XMLbczYhiv6E/qfNsVr31YUow6DoFH6Sunhkb6 BVMJvU+ET9SioKzrSrIQBXU3mM7RiGRvhZwlhfTl2YJxudtQneexX3DvTgdF6NYgJNshIL0R48 cqo= X-IronPort-AV: E=Sophos;i="5.81,164,1610438400"; d="diff'?scan'208";a="57907329" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 09 Feb 2021 03:52:56 -0800 IronPort-SDR: NHn8kuJkiskc0t3BFWuJV1iTze03qG3HS8XhBrL02vYVfEBNVLDPvxOIgy0m9UGTVInFQ8OSDX anE12N4BqEGnuE6v6fj8STfCmmSHU+QfJsgYaQDl9URT7EYOIBK56hc873muYp5gh/xSPHo5M9 0F+nZHRHnc/7Ct1vkE+uu+kpAa0MyWGqnqAZhXE3B6JXq7M0qwUw+/4CqHxUDVOkwesyxp0AnZ EKVQtCbuMA/hIL9Jv15JGrtoUa1cRejWuK7D4Yp6j8g+5EvuMakhQexvpZv4MfGT8MIONLm1L/ p40= Subject: [Patch] Fortran: Fix coarray handling for gfc_dep_resolver [PR99010] (was: Re: [Patch] Fortran: Fix Array dependency with local coarrays [PR98913] From: Tobias Burnus To: Thomas Koenig , Jorge D'Elia , Gfortran List , gcc-patches References: <121178681.597.1612108263047.JavaMail.zimbra@intec.unl.edu.ar> <9d298701-38a5-c2c5-1daf-7a2dad754369@netcologne.de> <4fc42e9c-676d-f3fc-57ab-f665a679bfbb@codesourcery.com> <7098734c-32bb-a5d0-1e72-015e33321dc9@netcologne.de> <5eab30e5-5322-bfee-349b-c6c7ec1fb47b@codesourcery.com> Message-ID: Date: Tue, 9 Feb 2021 12:52:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <5eab30e5-5322-bfee-349b-c6c7ec1fb47b@codesourcery.com> Content-Type: multipart/mixed; boundary="------------9E8CCA0FCD2F236786CBB49B" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2021 11:52:59 -0000 --------------9E8CCA0FCD2F236786CBB49B Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Hi all, hi Thomas, On 02.02.21 18:15, Tobias Burnus wrote: > I think I will do a combination: If 'identical' is true, I think I > cannot remove it. If it is false, it can be identical or nonoverlapping > =E2=80=93 which makes sense. Well, it turned out that coarray scalars did not work; for them, the array ref consists only of the coindexed access: falling through then triggered as fin_dep =3D=3D GFC_DEP_ERROR. To be more careful, I also removed the 'identical &&' check such that the first loop is now always triggered if coarray !=3D SINGLE not only if identical =E2=80=93 I am not sure whether it is really needed or whether falling though is the better solution (with updating the comment). I would be happy if someone could carefully check the logic =E2=80=93 in the details, it is rather confusing. OK? Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen R= egistergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas H= eurung, Frank Th=C3=BCrauf --------------9E8CCA0FCD2F236786CBB49B Content-Type: text/x-patch; charset="UTF-8"; name="caf-dep-fix.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="caf-dep-fix.diff" Fortran: Fix coarray handling for gfc_dep_resolver [PR99010] Check failed if identical = false was requested or for -fcoarray=single if an array ref was for a coindexed scalar. gcc/fortran/ChangeLog: PR fortran/99010 * dependency.c (gfc_dep_resolver): Fix coarray handling. gcc/testsuite/ChangeLog: PR fortran/99010 * gfortran.dg/coarray/array_temporary-1.f90: New test. gcc/fortran/dependency.c | 14 +++++++++++--- gcc/testsuite/gfortran.dg/coarray/array_temporary-1.f90 | 13 +++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 5de3b2cf520..e1336e1c654 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -2145,9 +2145,9 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse, case REF_ARRAY: /* Coarrays: If there is a coindex, either the image differs and there is no overlap or the image is the same - then the normal analysis - applies. Hence, return early only if 'identical' is required and - either ref is coindexed and more than one image can exist. */ - if (identical && flag_coarray != GFC_FCOARRAY_SINGLE + applies. Hence, return early if either ref is coindexed and more + than one image can exist. */ + if (flag_coarray != GFC_FCOARRAY_SINGLE && ((lref->u.ar.codimen && lref->u.ar.dimen_type[lref->u.ar.dimen] != DIMEN_THIS_IMAGE) @@ -2155,6 +2155,14 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse, && lref->u.ar.dimen_type[lref->u.ar.dimen] != DIMEN_THIS_IMAGE))) return 1; + if (lref->u.ar.dimen == 0 || rref->u.ar.dimen == 0) + { + /* Coindexed scalar coarray with GFC_FCOARRAY_SINGLE. */ + if (lref->u.ar.dimen || rref->u.ar.dimen) + return 1; /* Just to be sure. */ + fin_dep = GFC_DEP_EQUAL; + break; + } if (ref_same_as_full_array (lref, rref)) return identical; diff --git a/gcc/testsuite/gfortran.dg/coarray/array_temporary-1.f90 b/gcc/testsuite/gfortran.dg/coarray/array_temporary-1.f90 new file mode 100644 index 00000000000..454929cf53b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/coarray/array_temporary-1.f90 @@ -0,0 +1,13 @@ +! PR fortran/99010 +! +! Follow-up to PR fortran/98913 +! +! Contributed by G. Steinmetz +! +program p + integer :: x[*] + x = this_image() + if ( this_image() == 2 ) then + x = x[1] + end if +end --------------9E8CCA0FCD2F236786CBB49B--