Hi,

The percentage sign as first character of a ptx identifier can be used to
avoid name conflicts, e.g., between user-defined variable names and
compiler-generated names.

The insn nvptx_uniform_warp_check contains register names without '%' prefix,
which potentially could lead to name conflicts with user-defined variable
names.

Fix this by adding a '%' prefix, more specifically a '%r_' prefix to avoid a
name conflict with ptx special registers.

Tested on x86_64 with nvptx accelerator.

Committed to trunk.

Thanks,
- Tom

[nvptx] Use '%' as register prefix

gcc/ChangeLog:

2022-03-20  Tom de Vries  <tdevr...@suse.de>

        PR target/104925
        * config/nvptx/nvptx.md (define_insn "nvptx_uniform_warp_check"):
        Use % as register prefix.

---
 gcc/config/nvptx/nvptx.md | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 5550ce25513..8ed685027b5 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -2280,13 +2280,14 @@ (define_insn "nvptx_uniform_warp_check"
   {
     const char *insns[] = {
       "{",
-      "\\t"          ".reg.b32"        "\\t" "act;",
-      "%.\\t"        "vote.ballot.b32" "\\t" "act,1;",
-      "\\t"          ".reg.pred"       "\\t" "do_abort;",
-      "\\t"          "mov.pred"        "\\t" "do_abort,0;",
-      "%.\\t"        "setp.ne.b32"     "\\t" "do_abort,act,0xffffffff;",
-      "@ do_abort\\t" "trap;",
-      "@ do_abort\\t" "exit;",
+      "\\t"              ".reg.b32"        "\\t" "%%r_act;",
+      "%.\\t"            "vote.ballot.b32" "\\t" "%%r_act,1;",
+      "\\t"              ".reg.pred"       "\\t" "%%r_do_abort;",
+      "\\t"              "mov.pred"        "\\t" "%%r_do_abort,0;",
+      "%.\\t"            "setp.ne.b32"     "\\t" "%%r_do_abort,%%r_act,"
+                                                 "0xffffffff;",
+      "@ %%r_do_abort\\t" "trap;",
+      "@ %%r_do_abort\\t" "exit;",
       "}",
       NULL
     };

Reply via email to