[llvm] e7db113 - [AMDGPU] Remove redundant AGPR/VGPR register class verification (#212721)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 29 03:35:47 PDT 2026


Author: Arseniy Obolenskiy
Date: 2026-07-29T12:35:43+02:00
New Revision: e7db113dca5582f512e95053dd1b770f594ae2e8

URL: https://github.com/llvm/llvm-project/commit/e7db113dca5582f512e95053dd1b770f594ae2e8
DIFF: https://github.com/llvm/llvm-project/commit/e7db113dca5582f512e95053dd1b770f594ae2e8.diff

LOG: [AMDGPU] Remove redundant AGPR/VGPR register class verification (#212721)

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
    llvm/test/MachineVerifier/AMDGPU/verify-ds-vdata-vdst-both-agpr-or-vgpr.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index b2c3772cb0041..0b07d970654bd 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -5853,20 +5853,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
     if (Data && !Data->isReg())
       Data = nullptr;
 
-    if (ST.hasGFX90AInsts()) {
-      if (Dst && Data && !Dst->isTied() && !Data->isTied() &&
-          (RI.isAGPR(MRI, Dst->getReg()) != RI.isAGPR(MRI, Data->getReg()))) {
-        ErrInfo = "Invalid register class: "
-                  "vdata and vdst should be both VGPR or AGPR";
-        return false;
-      }
-      if (Data && Data2 &&
-          (RI.isAGPR(MRI, Data->getReg()) != RI.isAGPR(MRI, Data2->getReg()))) {
-        ErrInfo = "Invalid register class: "
-                  "both data operands should be VGPR or AGPR";
-        return false;
-      }
-    } else {
+    if (!ST.hasGFX90AInsts()) {
       if ((Dst && RI.isAGPR(MRI, Dst->getReg())) ||
           (Data && RI.isAGPR(MRI, Data->getReg())) ||
           (Data2 && RI.isAGPR(MRI, Data2->getReg()))) {

diff  --git a/llvm/test/MachineVerifier/AMDGPU/verify-ds-vdata-vdst-both-agpr-or-vgpr.mir b/llvm/test/MachineVerifier/AMDGPU/verify-ds-vdata-vdst-both-agpr-or-vgpr.mir
index dc01507df5e26..75d1d6152c886 100644
--- a/llvm/test/MachineVerifier/AMDGPU/verify-ds-vdata-vdst-both-agpr-or-vgpr.mir
+++ b/llvm/test/MachineVerifier/AMDGPU/verify-ds-vdata-vdst-both-agpr-or-vgpr.mir
@@ -11,15 +11,12 @@ body:             |
   %agpr:agpr_32 = IMPLICIT_DEF
   %a_or_v:av_32 = IMPLICIT_DEF
 
-  ; CHECK: Bad machine code: Invalid register class: vdata and vdst should be both VGPR or AGPR
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %4:agpr_32 = DS_CMPST_RTN_B32_gfx9 %addr, %vgpr, %vgpr, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
-  ; CHECK: Bad machine code: Invalid register class: vdata and vdst should be both VGPR or AGPR
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %5:vgpr_32 = DS_CMPST_RTN_B32_gfx9 %addr, %agpr, %vgpr, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: both data operands should be VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %6:vgpr_32 = DS_CMPST_RTN_B32_gfx9 %addr, %vgpr, %agpr, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
@@ -32,25 +29,21 @@ body:             |
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %9:vgpr_32 = DS_CMPST_RTN_B32_gfx9 %vgpr, %vgpr, %a_or_v, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: vdata and vdst should be both VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %10:av_32 = DS_CMPST_RTN_B32_gfx9 %addr, %agpr, %agpr, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: vdata and vdst should be both VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %11:agpr_32 = DS_CMPST_RTN_B32_gfx9 %addr, %a_or_v, %agpr, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: both data operands should be VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   %12:agpr_32 = DS_CMPST_RTN_B32_gfx9 %addr, %agpr, %a_or_v, 0, 0, implicit $exec :: (load store seq_cst monotonic (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: vdata and vdst should be both VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
@@ -65,11 +58,9 @@ body:             |
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   DS_WRITE2_B32_gfx9 %addr, %a_or_v, %a_or_v, 10, 24, 0, implicit $exec :: (store (s32), addrspace 3), (store (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: both data operands should be VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   DS_WRITE2_B32_gfx9 %addr, %agpr, %vgpr, 10, 24, 0, implicit $exec :: (store (s32), addrspace 3), (store (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: both data operands should be VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   DS_WRITE2_B32_gfx9 %addr, %vgpr, %agpr, 10, 24, 0, implicit $exec :: (store (s32), addrspace 3), (store (s32), addrspace 3)
 
@@ -79,12 +70,10 @@ body:             |
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   DS_WRITE2_B32_gfx9 %addr, %a_or_v, %vgpr, 10, 24, 0, implicit $exec :: (store (s32), addrspace 3), (store (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: both data operands should be VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   DS_WRITE2_B32_gfx9 %addr, %agpr, %a_or_v, 10, 24, 0, implicit $exec :: (store (s32), addrspace 3), (store (s32), addrspace 3)
 
-  ; CHECK: *** Bad machine code: Invalid register class: both data operands should be VGPR or AGPR ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   ; CHECK: *** Bad machine code: Illegal virtual register for instruction ***
   DS_WRITE2_B32_gfx9 %addr, %a_or_v, %agpr, 10, 24, 0, implicit $exec :: (store (s32), addrspace 3), (store (s32), addrspace 3)


        


More information about the llvm-commits mailing list