public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7585] [nvptx] Handle unused result in nvptx_unisimt_handle_set
@ 2022-03-10 11:22 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2022-03-10 11:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3e743d654b3598d54b3c2eb837a48baeac00a543
commit r12-7585-g3e743d654b3598d54b3c2eb837a48baeac00a543
Author: Tom de Vries <tdevries@suse.de>
Date: Mon Mar 7 15:57:11 2022 +0100
[nvptx] Handle unused result in nvptx_unisimt_handle_set
For an example:
...
#pragma omp target map(tofrom: counter_N0)
#pragma omp simd
for (int i = 0 ; i < 1 ; i++ )
{
#pragma omp atomic update
counter_N0 = counter_N0 + 1 ;
}
...
I noticed that the result of the atomic update (%r30) is propagated:
...
@%r33 atom.add.u32 _, [%r29], 1;
shfl.sync.idx.b32 %r30, %r30, %r32, 31, 0xffffffff;
...
even though it is unused (which is why the bit bucket operand _ is used).
Fix this by not emitting the shuffle in this case, such that we have instead:
...
@%r33 atom.add.u32 _, [%r29], 1;
bar.warp.sync 0xffffffff;
...
Tested on nvptx.
gcc/ChangeLog:
2022-03-07 Tom de Vries <tdevries@suse.de>
* config/nvptx/nvptx.cc (nvptx_unisimt_handle_set): Handle unused
result.
gcc/testsuite/ChangeLog:
2022-03-07 Tom de Vries <tdevries@suse.de>
* gcc.target/nvptx/uniform-simt-4.c: New test.
Diff:
---
gcc/config/nvptx/nvptx.cc | 4 +++-
gcc/testsuite/gcc.target/nvptx/uniform-simt-4.c | 22 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 14911bd15f1..c41e305a34f 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -3274,7 +3274,9 @@ static bool
nvptx_unisimt_handle_set (rtx set, rtx_insn *insn, rtx master)
{
rtx reg;
- if (GET_CODE (set) == SET && REG_P (reg = SET_DEST (set)))
+ if (GET_CODE (set) == SET
+ && REG_P (reg = SET_DEST (set))
+ && find_reg_note (insn, REG_UNUSED, reg) == NULL_RTX)
{
emit_insn_after (nvptx_gen_shuffle (reg, reg, master, SHUFFLE_IDX),
insn);
diff --git a/gcc/testsuite/gcc.target/nvptx/uniform-simt-4.c b/gcc/testsuite/gcc.target/nvptx/uniform-simt-4.c
new file mode 100644
index 00000000000..c33de7a4111
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/uniform-simt-4.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -muniform-simt -mptx=_" } */
+
+enum memmodel
+{
+ MEMMODEL_RELAXED = 0
+};
+
+unsigned long long int *p64;
+unsigned long long int v64;
+
+int
+main()
+{
+ __atomic_fetch_add (p64, v64, MEMMODEL_RELAXED);
+
+ return 0;
+}
+
+/* { dg-final { scan-assembler-times "atom.add.u64\[\t \]+_," 1 } } */
+/* { dg-final { scan-assembler-times "bar.warp.sync" 1 } } */
+/* { dg-final { scan-assembler-not "shfl.sync.idx" } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-10 11:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 11:22 [gcc r12-7585] [nvptx] Handle unused result in nvptx_unisimt_handle_set Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).