From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 16DB1386F473; Mon, 1 Feb 2021 11:20:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16DB1386F473 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBmb3J0cmFuLzk4OTEzXSBOZXc6IENyZWF0ZS10ZW1wb3Jh?= =?UTF-8?B?cnkgZGlmZmVyZW5jZSBjb2FycmF5L25vbmNvYXJyYXkg4oCTIGludmFsaWQg?= =?UTF-8?B?Y29kZSBkdWUgdG8gbWlzc2luZyB0ZW1wb3Jhcnk=?= Date: Mon, 01 Feb 2021 11:20:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Feb 2021 11:20:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98913 Bug ID: 98913 Summary: Create-temporary difference coarray/noncoarray =E2=80=93 invalid code due to missing temporary Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jdelia at intec dot unl.edu.ar, tkoenig at gcc dot gnu.= org Target Milestone: --- Reported at https://gcc.gnu.org/pipermail/fortran/2021-January/055657.html The testcase there uses real (kind=3Didp), allocatable :: AA (:,:)[:] real (kind=3Didp), allocatable :: BB (:,:) For identical assignment, a temporary is generated for the (this_image()-access) coarray variable but not for the local variable: 37 | AA (k1:nn,j) =3D AA (k1:nn,j) - UU (k1:nn) * AA (k,j) | 1 Warning: Creating array temporary at (1) [-Warray-temporaries] On the compiler side, I think the behaviour differs due to: gfc_conv_resolve_dependencies(): if (flag_realloc_lhs && dest_expr !=3D ss_expr && gfc_is_reallocatable_lhs (dest_expr) && ss_expr->rank) nDepend =3D gfc_check_dependency (dest_expr, ss_expr, true); * * * Looking at do j =3D 1, nn AA (k1:nn,j) =3D AA (k1:nn,j) - UU (k1:nn) * AA (k,j) end do I think a temporary is needed for "A(k,j)", i.e. do j =3D 1, nn tmp =3D AA (k,j) do ii =3D k1, nn AA (ii,j) =3D AA (ii,j) - UU (ii) * tmp end do end do without that temporary, k might be any value within k1:nn! In this example, k =3D 1; k1 =3D 2 =E2=80=93 thus, there is no dependency. * * * For (b), I see (for "BB(k,j)"): D.3991 =3D (*(real(kind=3D8)[0:] * restrict) bb.data)[(bb.offset + (integer(kind=3D8)) j * bb.dim[1].stride) + (integer(kind=3D8)) k]; ... D.3986 =3D (real(kind=3D8)[0:] * restrict) bb.data; D.3978 =3D (real(kind=3D8)[0:] * restrict) bb.data; while (1) ... (*D.3986)[(S.0 + D.3994) + D.3997] =3D (*D.3978)[S.0 + D.= 3996] - (*D.3982)[(S.0 + D.3993) + D.3983] * D.3991; Namely: b(k,j) is accessed. I am quite certain that "k =3D 1; k1 =3D k + 1" is not used for this analys= is =E2=86=92 wrong code. If it is, it should also apply to coarrays.=