[llvm] [AMDGPU] Use Reg32Types for move-immediate patterns (PR #138422)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Sat May 3 13:08:53 PDT 2025


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/138422

This just avoids having another copy of the list of valid 32-bit pointer
types.


>From 238328fc3e31ee6a52e95886e30f9719336fb019 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Sat, 3 May 2025 21:03:45 +0100
Subject: [PATCH] [AMDGPU] Use Reg32Types for move-immediate patterns

This just avoids having another copy of the list of valid 32-bit pointer
types.
---
 llvm/lib/Target/AMDGPU/SIInstructions.td | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index f5c6d47369781..dea20e2d84d7b 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -2270,16 +2270,18 @@ def : GCNPat <
 
 // FIXME: Remove VGPRImm. Should be inferrable from register bank.
 
-foreach vt = [i32, p3, p5, p6, p2] in {
-  def : GCNPat <
-    (VGPRImm<(vt imm)>:$imm),
-    (V_MOV_B32_e32 imm:$imm)
-  >;
+foreach vt = Reg32Types.types in {
+  if !and(!not(vt.isVector), !not(vt.isFP)) then {
+    def : GCNPat <
+      (VGPRImm<(vt imm)>:$imm),
+      (V_MOV_B32_e32 imm:$imm)
+    >;
 
-  def : GCNPat <
-    (vt imm:$imm),
-    (S_MOV_B32 imm:$imm)
-  >;
+    def : GCNPat <
+      (vt imm:$imm),
+      (S_MOV_B32 imm:$imm)
+    >;
+  }
 }
 
 // FIXME: The register bank of the frame index should depend on the



More information about the llvm-commits mailing list