[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:53:35 PDT 2026


https://github.com/chinmaydd created https://github.com/llvm/llvm-project/pull/223587

CU mode is only meaningful on targets that support WGP execution. However,
`isFullSIMDMode()` currently treats `+cumode` as effective on every target.

On pre-gfx10 targets this incorrectly selects half-SIMD mode, halving both the
physical and addressable LDS sizes. For example, gfx942 reports a 32 KiB limit
instead of 64 KiB, while gfx950 reports 80 KiB instead of 160 KiB. This caused
`CodeGen/AMDGPU/lds-limit-diagnostics.ll` to fail in ROCm CI after #220718.

>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] [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.
 



More information about the llvm-commits mailing list