From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DC4CA3858D1E; Tue, 8 Feb 2022 08:06:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC4CA3858D1E From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104440] New: nvptx: FAIL: gcc.c-torture/execute/pr53465.c execution test Date: Tue, 08 Feb 2022 08:06:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries 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 bug_severity priority component assigned_to reporter 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: Tue, 08 Feb 2022 08:06:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104440 Bug ID: 104440 Summary: nvptx: FAIL: gcc.c-torture/execute/pr53465.c execution test Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- With nvptx target, driver version 510.47.03 and board GT 1030 I run into: ... FAIL: gcc.c-torture/execute/pr53465.c -O1 execution test FAIL: gcc.c-torture/execute/pr53465.c -O2 execution test FAIL: gcc.c-torture/execute/pr53465.c -O3 -g execution test ... Passes with nvptx-none-run -O0: ... $ ( export NVPTX_NONE_RUN=3D"$(pwd -P)/install/bin/nvptx-none-run -O0" ; ./test.sh ) =3D=3D=3D gcc Summary =3D=3D=3D # of expected passes 12 $ ... I can minimize it at -O1 to: ... void __attribute__((noinline, noclone)) foo (int y) { int i; int c; for (i =3D 0; i < y; i++) { int d =3D i + 1; if (i && d <=3D c) __builtin_abort (); c =3D d; } } int main () { foo (2); return 0; } ... I can make the test pass by initializing c with any value (or by doing the equivalent at ptx level). Note that the read of c in the loop body only happens in the second iterati= on, by which time it's initialized, so the example is valid. Gcc however translates this at gimple level to: ... _1 =3D i !=3D 0; _2 =3D d <=3D c; _3 =3D _1 & _2; ... which does imply a read of c while it's undefined. We can prevent this by using --param=3Dlogical-op-non-short-circuit=3D0, an= d that makes the minimized example pass. But not the original example. If we translate the example into cuda, we see that the loop's first iterati= on is peeled off, even at -O0. This has the effect that there are two "d <=3D= c" tests. The first one has an undefined input, but is dead code. The second= one has its inputs defined on both loop entry and backedge. We could try to report this to nvidia, but I'm not sure they want to fix th= is. They've pushed back on examples involving reads from uninitialized regs bef= ore, and looking at what cuda does, it seems they try to ensure this invariant. Unfortunately, pass_initialize_regs does not insert the required init. So, it looks like we'll have to fix this in the compiler.=