[llvm] [AMDGPU] Do not use s_delay_alu instskip to skip s_set_vgpr_msb (PR #175925)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 08:53:28 PST 2026


https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/175925

>From b92baa23aa638b55fd4eeb1edd4b1731e9b27560 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 14 Jan 2026 11:25:04 +0000
Subject: [PATCH 1/3] [AMDGPU] Do not use s_delay_alu instskip to skip
 s_set_vgpr_msb

---
 llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
index 5f4ca82132335..bc416bba6278d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
@@ -325,6 +325,10 @@ class AMDGPUInsertDelayAlu {
       for (auto I = MachineBasicBlock::instr_iterator(LastDelayAlu),
                 E = MachineBasicBlock::instr_iterator(MI);
            ++I != E;) {
+        if (I->getOpcode() == AMDGPU::S_SET_VGPR_MSB) {
+          Skip = 6;
+          break;
+        }
         if (!I->isBundle() && !I->isMetaInstruction())
           ++Skip;
       }

>From a956d6590d2eb7b3b336fa4a98e7f9319c31d142 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Mon, 19 Jan 2026 16:39:20 +0000
Subject: [PATCH 2/3] Update tests

---
 llvm/test/CodeGen/AMDGPU/vgpr-lowering-gfx1250.mir | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/test/CodeGen/AMDGPU/vgpr-lowering-gfx1250.mir b/llvm/test/CodeGen/AMDGPU/vgpr-lowering-gfx1250.mir
index a2b5ef7771c09..be2a4d56cad08 100644
--- a/llvm/test/CodeGen/AMDGPU/vgpr-lowering-gfx1250.mir
+++ b/llvm/test/CodeGen/AMDGPU/vgpr-lowering-gfx1250.mir
@@ -60,6 +60,7 @@ body:             |
     ; Tuple crossing the 256 boundary
     ; GCN-NEXT: s_set_vgpr_msb 0x5511
     ; ASM-SAME:                                         ;  msbs: dst=0 src0=1 src1=0 src2=1
+    ; GCN-NEXT: s_delay_alu instid0(VALU_DEP_1)
     ; GCN-NEXT: v_mqsad_u32_u8 v[254:257], v[2:3] /*v[258:259]*/, v0, v[244:247] /*v[500:503]*/
     $vgpr254_vgpr255_vgpr256_vgpr257 = V_MQSAD_U32_U8_e64 $vgpr258_vgpr259, $vgpr0, undef $vgpr500_vgpr501_vgpr502_vgpr503, 0, implicit $exec
 

>From 5ebbd59bb899dc69e525656766679dbdea023ca7 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Mon, 19 Jan 2026 16:41:49 +0000
Subject: [PATCH 3/3] Add comments

---
 llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
index bc416bba6278d..f3d17862e3e1c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp
@@ -326,6 +326,9 @@ class AMDGPUInsertDelayAlu {
                 E = MachineBasicBlock::instr_iterator(MI);
            ++I != E;) {
         if (I->getOpcode() == AMDGPU::S_SET_VGPR_MSB) {
+          // It is not deterministic whether the skip count counts
+          // S_SET_VGPR_MSB instructions or not, so do not include them in a
+          // skip region.
           Skip = 6;
           break;
         }



More information about the llvm-commits mailing list