aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2022-02-18 17:38:50 +0100
committerTom de Vries <tdevries@suse.de>2022-02-19 19:57:12 +0100
commit9ed52438b8ca99a0dffe74da96c2281cbc9cbb4b (patch)
treed90c1198bbc833573d4b2a688ad49f7d699a4b6e
parent8e5c34ab45f34aadea65c5ba33ec685264b6ec66 (diff)
downloadgcc-9ed52438b8ca99a0dffe74da96c2281cbc9cbb4b.zip
gcc-9ed52438b8ca99a0dffe74da96c2281cbc9cbb4b.tar.gz
gcc-9ed52438b8ca99a0dffe74da96c2281cbc9cbb4b.tar.bz2
[nvptx] Don't skip atomic insns in nvptx_reorg_uniform_simt
In nvptx_reorg_uniform_simt we have a loop: ... for (insn = get_insns (); insn; insn = next) { next = NEXT_INSN (insn); if (!(CALL_P (insn) && nvptx_call_insn_is_syscall_p (insn)) && !(NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == PARALLEL && get_attr_atomic (insn))) continue; ... that intends to handle syscalls and atomic insns. However, this also silently skips the atomic insn nvptx_atomic_store, which has GET_CODE (PATTERN (insn)) == SET. This does not cause problems, because the nvptx_atomic_store actually maps onto a "st" insn, and therefore is not atomic and doesn't need to be handled by nvptx_reorg_uniform_simt. Fix this by: - explicitly setting nvptx_atomic_store's atomic attribute to false, - rewriting the skip condition to make sure all insn with atomic attribute are handled, and - asserting that all handled insns are PARALLEL. Tested on nvptx. gcc/ChangeLog: 2022-02-19 Tom de Vries <tdevries@suse.de> * config/nvptx/nvptx.cc (nvptx_reorg_uniform_simt): Handle all insns with atomic attribute. Assert that all handled insns are PARALLELs. * config/nvptx/nvptx.md (define_insn "nvptx_atomic_store<mode>"): Set atomic attribute to false. gcc/testsuite/ChangeLog: 2022-02-19 Tom de Vries <tdevries@suse.de> * gcc.target/nvptx/uniform-simt-3.c: New test.
-rw-r--r--gcc/config/nvptx/nvptx.cc20
-rw-r--r--gcc/config/nvptx/nvptx.md2
-rw-r--r--gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c4
3 files changed, 21 insertions, 5 deletions
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 4942f11..55fab3e 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -3274,12 +3274,24 @@ nvptx_reorg_uniform_simt ()
for (insn = get_insns (); insn; insn = next)
{
next = NEXT_INSN (insn);
- if (!(CALL_P (insn) && nvptx_call_insn_is_syscall_p (insn))
- && !(NONJUMP_INSN_P (insn)
- && GET_CODE (PATTERN (insn)) == PARALLEL
- && get_attr_atomic (insn)))
+
+ /* Skip NOTE, USE, etc. */
+ if (!INSN_P (insn) || recog_memoized (insn) == -1)
continue;
+
+ if (CALL_P (insn) && nvptx_call_insn_is_syscall_p (insn))
+ {
+ /* Handle syscall. */
+ }
+ else if (get_attr_atomic (insn))
+ {
+ /* Handle atomic insn. */
+ }
+ else
+ continue;
+
rtx pat = PATTERN (insn);
+ gcc_assert (GET_CODE (pat) == PARALLEL);
rtx master = nvptx_get_unisimt_master ();
bool shuffle_p = false;
for (int i = 0; i < XVECLEN (pat, 0); i++)
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 4c378ec..132ef2f 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -2097,7 +2097,7 @@
= "%.\tst%A0.b%T0\t%0, %1;";
return nvptx_output_atomic_insn (t, operands, 0, 2);
}
- [(set_attr "atomic" "true")])
+ [(set_attr "atomic" "false")]) ;; Note: st is not an atomic insn.
(define_insn "atomic_fetch_add<mode>"
[(set (match_operand:SDIM 1 "memory_operand" "+m")
diff --git a/gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c b/gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c
new file mode 100644
index 0000000..532fa82
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/uniform-simt-3.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -muniform-simt -misa=sm_75" } */
+
+#include "atomic-store-2.c"