From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 41C01388C031; Wed, 10 Jun 2020 09:08:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41C01388C031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591780092; bh=c6LwRgNOCuIMjJEp+JKEyWc0+OSdWrsfBD5yntMliRg=; h=From:To:Subject:Date:From; b=ZcXxUSmFwA6BNESRHs+LQFWQr4YMhmEurmR8iu7BWqvxf7Yo7dmWqFUGGY84jCYph qBs+NbDG04Q5dUwTdb02ptKEI1auJCq07l8SZwHvOxVJRSbL6ZLR0MyhtqaMadfDi1 8Rav/qoG44gEnqJnEDwPLz9Zmkh2O9p0eJpoXQFc= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/95622] New: force_output flag on a variable prevents optimization / regresses c-c++-common/goacc/kernels-alias-ipa-pta-2.c Date: Wed, 10 Jun 2020 09:08: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: 10.0 X-Bugzilla-Keywords: missed-optimization, openacc, openmp 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, 10 Jun 2020 09:08:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95622 Bug ID: 95622 Summary: force_output flag on a variable prevents optimization / regresses c-c++-common/goacc/kernels-alias-ipa-pta-2.c Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: missed-optimization, openacc, openmp 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 Target Milestone: --- The following only shows up as FAIL in the testsuite if ENABLE_OFFLOAD is true, even though it is only a compile-time test. [Hence, it can make sen= se to not only "make check-target-libgomp" with an offloading compiler but also gcc/.] Somewhat similar to PR 68773. The testcase: c-c++-common/goacc/kernels-alias-ipa-pta-2.c =E2=80=A6 { a[0] =3D 0; b[0] =3D 1; c[0] =3D a[0]; } =E2=80=A6 Without ENABLE_OFFLOAD or before r11-1075-g1c0fdaf79e3618fd7512608a2e5c62b6b306e9e8 (for PR94848 + PR95551): MEM[(unsigned int *)_5] =3D 0; // a[0] =3D 0 MEM[(unsigned int *)_4] =3D 1; // b[0] =3D 1 MEM[(unsigned int *)_3] =3D 0; // c[0] =3D a[0] With r11-1075 + offloading compiler, force_output is on offloading variables (to ensure they are not optimized away), the last line becomes _8 =3D MEM[(unsigned int *)_5]; // _8 =3D a[0] MEM[(unsigned int *)_3] =3D _8; // c[0] =3D _8 Expected: force_output does not affect the optimization. (Especially as "a" cannot be optimized away as it is also used for "copyout".) [A very well optimizing compiler could see that nothing uses a/b/c after the target section and could replace the whole function body by "{ }"=E2=80=A6]=