From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 17D273858413; Wed, 17 Aug 2022 09:00:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17D273858413 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/106662] New: [OpenMP] 'for simd firstprivate(j) lastprivate(j)' with 'parallel shared(j)' gives unexpected result Date: Wed, 17 Aug 2022 09:00:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: openmp, 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: Wed, 17 Aug 2022 09:00:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106662 Bug ID: 106662 Summary: [OpenMP] 'for simd firstprivate(j) lastprivate(j)' with 'parallel shared(j)' gives unexpected result Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: openmp, wrong-code Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org, sandra at gcc dot gnu.org Target Milestone: --- [Lightly related to PR106504 - but that one uses 'parallel private' not shared.] The following program, converted to C++ from libgomp.fortran/pr27416-1.f90 and with 'simd' added to the workshare-loop construct, yields: * 22 with 'for' - i.e. the existing Fortran testcase, but C++-ified. and independent of 'num_threads(1)' * 22 with clang++-12 * 22 with icc 19 while * 16 is obtained with GCC (as if 0 and not 6 is firstprivatized) int main()=20=20 {=20=20=20=20=20=20=20 int j =3D 6; #pragma omp parallel num_threads (4) shared(j) {=20=20=20=20=20 int i; #pragma omp for simd firstprivate (j) lastprivate (j) // private(i) for (i =3D 1; i <=3D 16; ++i) if (i =3D=3D 16) j =3D j + i; }=20=20=20=20=20 __builtin_printf("j =3D %i =3D?=3D %i\n", j, 6+16); if (j !=3D 6+16) __builtin_abort(); return 0; } Likewise with a combined construct: ... #pragma omp parallel for simd num_threads (4) firstprivate (j) lastprivate (j) for (int i =3D 1; i <=3D 16; ++i) ... And likewise with the equivalent Fortran code.=