]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
nvptx: Correct pattern for popcountdi2 insn in nvptx.md.
authorRoger Sayle <roger@nextmovesoftware.com>
Sun, 19 May 2024 08:49:45 +0000 (09:49 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Sun, 19 May 2024 08:49:45 +0000 (09:49 +0100)
The result of a POPCOUNT operation in RTL should have the same mode
as its operand.  This corrects the specification of popcount in
the nvptx backend, splitting the current generic define_insn into
two, one for popcountsi2 and the other for popcountdi2 (the latter
with an explicit truncate).

2024-05-19  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* config/nvptx/nvptx.md (popcount<mode>2): Split into...
(popcountsi2): define_insn handling SImode popcount.
(popcountdi2): define_insn handling DImode popcount, with an
explicit truncate:SI to produce an SImode result.

gcc/config/nvptx/nvptx.md

index 96e6c91160808ae19e3b592ed865d4cd6f85c0a1..ef7e3fb00fac86a59d53eba6c897c844f44f47e2 100644 (file)
   DONE;
 })
 
-(define_insn "popcount<mode>2"
+(define_insn "popcountsi2"
   [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
-       (popcount:SI (match_operand:SDIM 1 "nvptx_register_operand" "R")))]
+       (popcount:SI (match_operand:SI 1 "nvptx_register_operand" "R")))]
   ""
-  "%.\\tpopc.b%T1\\t%0, %1;")
+  "%.\\tpopc.b32\\t%0, %1;")
+
+(define_insn "popcountdi2"
+  [(set (match_operand:SI 0 "nvptx_register_operand" "=R")
+       (truncate:SI
+         (popcount:DI (match_operand:DI 1 "nvptx_register_operand" "R"))))]
+  ""
+  "%.\\tpopc.b64\\t%0, %1;")
 
 ;; Multiplication variants