[llvm] [AMDGPU] Fix LDS reporting for targets without CU mode (PR #223587)
Chinmay Deshpande via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 14 19:58:41 PDT 2026
https://github.com/chinmaydd updated https://github.com/llvm/llvm-project/pull/223587
>From d220ed9693893cca4719b9127f2857544b028264 Mon Sep 17 00:00:00 2001
From: Chinmay Deshpande <chdeshpa at amd.com>
Date: Mon, 14 Sep 2026 22:51:06 -0400
Subject: [PATCH 1/2] [AMDGPU] Fix LDS reporting for targets without CU mode
Change-Id: Ib3d3061b153e391c841bdd9ae34080af1d965a1b
---
llvm/lib/Target/AMDGPU/GCNSubtarget.h | 2 +-
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp | 4 +++-
llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll | 5 +++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index 3c42fd40fbabc..c08134119d874 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -366,7 +366,7 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
/// \returns Whether a work-group runs on all of the block's SIMDs.
bool isFullSIMDMode() const {
- return (HasGFX1250Insts && getGeneration() < GFX13) || !EnableCuMode;
+ return !hasSupportsWGP() || !EnableCuMode;
}
bool isPreciseMemoryEnabled() const { return EnablePreciseMemory; }
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index 58ca7e69cecf8..39754cdd2e7e9 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -2528,7 +2528,9 @@ bool isGFX1250(const MCSubtargetInfo &STI) {
}
bool isFullSIMDMode(const MCSubtargetInfo &STI) {
- return isGFX1250(STI) || !STI.getFeatureBits().test(FeatureCuMode);
+ // CU mode is only meaningful on targets that have WGP mode. Elsewhere the
+ // feature may still be requested, but it has no effect.
+ return !supportsWGP(STI) || !STI.getFeatureBits().test(FeatureCuMode);
}
bool isGFX1250Plus(const MCSubtargetInfo &STI) {
diff --git a/llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll b/llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll
index 008f8e74de8b1..5f6e22c978760 100644
--- a/llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll
+++ b/llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll
@@ -15,6 +15,11 @@
; RUN: not llc -mtriple=amdgpu7.00-amd-amdhsa -filetype=null %s 2>&1 | FileCheck -check-prefix=ERROR-LIMIT64K %s
; RUN: not llc -mtriple=amdgpu6.00-amd-amdpal -filetype=null %s 2>&1 | FileCheck -check-prefix=ERROR-LIMIT32K %s
+; Pre-gfx10 has no WGP mode, so +cumode must not change the limit.
+; RUN: not llc -mtriple=amdgpu9.42-amd-amdhsa -mattr=+cumode -filetype=null %s 2>&1 | FileCheck -check-prefix=ERROR-LIMIT64K %s
+; RUN: not llc -mtriple=amdgpu9.0a-amd-amdhsa -mattr=+cumode -filetype=null %s 2>&1 | FileCheck -check-prefix=ERROR-LIMIT64K %s
+; RUN: not llc -mtriple=amdgpu9.50-amd-amdhsa -mattr=+cumode -filetype=null %s 2>&1 | FileCheck -check-prefix=ERROR-LIMIT160K %s
+
; gfx950 supports upto 160 KB LDS memory. The generic target does not.
; This is a negative test to check when the LDS size exceeds the max usable limit.
>From 0370a37e22b4edddbd3c629bebad0bb06a5ababb Mon Sep 17 00:00:00 2001
From: Chinmay Deshpande <chdeshpa at amd.com>
Date: Mon, 14 Sep 2026 19:58:32 -0700
Subject: [PATCH 2/2] Apply batched suggestions from code review
Co-authored-by: Chinmay Deshpande <chdeshpa at amd.com>
---
llvm/lib/Target/AMDGPU/GCNSubtarget.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index c08134119d874..9763ace836b6f 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -365,9 +365,7 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
bool isCuModeEnabled() const { return EnableCuMode; }
/// \returns Whether a work-group runs on all of the block's SIMDs.
- bool isFullSIMDMode() const {
- return !hasSupportsWGP() || !EnableCuMode;
- }
+ bool isFullSIMDMode() const { return !hasSupportsWGP() || !EnableCuMode; }
bool isPreciseMemoryEnabled() const { return EnablePreciseMemory; }
More information about the llvm-commits
mailing list