[llvm] ad3539c - [amdgpu] Add HasBufferInv AMDGPUSubtargetFeature (#226254)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 11:52:23 PDT 2026
Author: Dan Zimmerman
Date: 2026-10-05T14:52:15-04:00
New Revision: ad3539cfe92c3860789b70aaccd2077f4026d4cb
URL: https://github.com/llvm/llvm-project/commit/ad3539cfe92c3860789b70aaccd2077f4026d4cb
DIFF: https://github.com/llvm/llvm-project/commit/ad3539cfe92c3860789b70aaccd2077f4026d4cb.diff
LOG: [amdgpu] Add HasBufferInv AMDGPUSubtargetFeature (#226254)
As suggested by @arsenm I've created a new `AMDGPUSubtargetFeature` to
test whether `buffer_inv` is available, as opposed to just using
`hasGFX940Insts` to gate whether or not it's available.
The aforementioned suggestion was in response to
https://github.com/llvm/llvm-project/pull/221115. I plan to use this
flag in that PR.
In addition to introducing this new feature, I use it in place of
`hasGFX940Insts` in `SIMemoryLegalizer` where it clearly is checking
whether it's safe to use `buffer_inv`. I didn't find any other obvious
place in the codebase which uses `hasGFX940Insts` as a predicate for
`buffer_inv`.
This was co-authored with codex. Every line was audited by me, though.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPU.td
llvm/lib/Target/AMDGPU/BUFInstructions.td
llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index d552eae9c08d3..f267072fd8896 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -510,6 +510,10 @@ defm GFX940Insts : AMDGPUSubtargetFeature<"gfx940-insts",
/*GenPredicate=*/0
>;
+defm BufferInvInst : AMDGPUSubtargetFeature<"buffer-inv-inst",
+ "Has buffer_inv instruction"
+>;
+
defm Permlane16Insts : AMDGPUSubtargetFeature<"permlane16-insts",
"Has v_permlane16_b32/v_permlanex16_b32 instructions"
>;
@@ -2105,6 +2109,7 @@ def FeatureISAVersion9_4_Common : FeatureSet<
FeatureAGPRAlloc,
FeatureTgSplitSupport,
FeatureGFX940Insts,
+ FeatureBufferInvInst,
FeatureRequiresAlignedVGPRs,
FeatureFmaMixInsts,
FeatureDLInsts,
@@ -3363,7 +3368,8 @@ def AMDGPUFrontendVisibleFeatures {
FeatureAtomicFaddRtnInsts, FeatureAtomicFlatPkAdd16Insts, FeatureAtomicGlobalPkAddBF16Inst,
FeatureBF16ConversionInsts,
FeatureBF16PackedInsts, FeatureBF16TransInsts, FeatureBF8ConversionScaleInsts,
- FeatureBVHRayTracingInsts, FeatureBitOp3Insts, FeatureCIInsts,
+ FeatureBVHRayTracingInsts, FeatureBitOp3Insts, FeatureBufferInvInst,
+ FeatureCIInsts,
FeatureClusters, FeatureCubeInsts, FeatureCvtPkNormVOP2Insts,
FeatureCvtSrPkBF16F32Inst, FeatureDLInsts, FeatureDPP,
FeatureDot10Insts, FeatureDot11Insts, FeatureDot12Insts,
diff --git a/llvm/lib/Target/AMDGPU/BUFInstructions.td b/llvm/lib/Target/AMDGPU/BUFInstructions.td
index 057c0f103ce80..6cb0f77e0dbeb 100644
--- a/llvm/lib/Target/AMDGPU/BUFInstructions.td
+++ b/llvm/lib/Target/AMDGPU/BUFInstructions.td
@@ -1429,7 +1429,7 @@ let SubtargetPredicate = HasAtomicFMinFMaxF64GlobalInsts in {
}
def BUFFER_INV : MUBUF_Invalidate<"buffer_inv"> {
- let SubtargetPredicate = isGFX940Plus;
+ let SubtargetPredicate = HasBufferInvInst;
let has_glc = 1;
let has_sccb = 1;
let InOperandList = (ins CPol_0:$cpol);
@@ -3660,10 +3660,8 @@ let AsmString = BUFFER_WBL2.Mnemonic, // drop flags
defm BUFFER_WBL2 : MUBUF_Real_gfx90a<0x28>;
defm BUFFER_INVL2 : MUBUF_Real_gfx90a<0x29>;
-let SubtargetPredicate = isGFX940Plus in {
def BUFFER_WBL2_gfx940 : MUBUF_Real_gfx940<0x28, BUFFER_WBL2>;
def BUFFER_INV_gfx940 : MUBUF_Real_gfx940<0x29, BUFFER_INV>;
-}
class MTBUF_Real_Base_vi <bits<4> op, MTBUF_Pseudo ps, int Enc> :
MTBUF_Real<ps>,
diff --git a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
index e818e06e3bb04..10804d65b82b0 100644
--- a/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
+++ b/llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp
@@ -1396,7 +1396,7 @@ bool SIGfx6CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
if (canAffectGlobalAddrSpace(AddrSpace)) {
switch (Scope) {
case SIAtomicScope::SYSTEM:
- if (ST.hasGFX940Insts()) {
+ if (ST.hasBufferInvInst()) {
// Ensures that following loads will not see stale remote VMEM data or
// stale local VMEM data with MTYPE NC. Local VMEM data with MTYPE RW
// and CC will never be stale due to the local memory probes.
@@ -1428,7 +1428,7 @@ bool SIGfx6CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
}
[[fallthrough]];
case SIAtomicScope::AGENT:
- if (ST.hasGFX940Insts()) {
+ if (ST.hasBufferInvInst()) {
// Ensures that following loads will not see stale remote date or local
// MTYPE NC global data. Local MTYPE RW and CC memory will never be
// stale due to the memory probes.
@@ -1445,7 +1445,7 @@ bool SIGfx6CacheControl::insertAcquire(MachineBasicBlock::iterator &MI,
break;
case SIAtomicScope::WORKGROUP:
if (TgSplitEnabled) {
- if (ST.hasGFX940Insts()) {
+ if (ST.hasBufferInvInst()) {
// In threadgroup split mode the waves of a work-group can be
// executing on
diff erent CUs. Therefore need to invalidate the L1
// which is per CU. Otherwise in non-threadgroup split mode all waves
More information about the llvm-commits
mailing list