← Back to Pull requests

[AMDGPU] Fix LDS reporting for targets without CU mode #223587

Open
chinmaydd opened this pull request with 13 lines diff across 3 files
View on GitHub
chinmaydd chinmaydd commented on Sep 15, 2026 02:53 UTC
Author

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.

Diff: 13 lines (+9 / -4) across 3 files Reviewer: chinmaydd Review duration: 111047m
All Vouch review confidence checks passed
Residual risk 0.10 = Change Risk (0.43) × (1 − Review Confidence (0.77)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 13 lines diff across 3 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.88 · 5 substantive comment(s)
0.88
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
76%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.158
Self Review self_review
0.140
Real PR Conversation Timeline
8 items
llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Sep 15, 2026 02:54 UTC
Bot

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Chinmay Deshpande (chinmaydd)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/223587.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.h (+1-1)

  • (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp (+3-1)

  • (modified) llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll (+5)
  • ``````

    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.
     
    
    
    ``````

    </details>

    github-actions[bot] github-actions[bot] commented on Sep 15, 2026 02:55 UTC
    Bot

    <!--LLVM CODE FORMAT COMMENT: {clang-format}-->

    :white_check_mark: With the latest revision this PR passed the C/C++ code formatter.

    chinmaydd chinmaydd commented on code on Sep 15, 2026 02:57 UTC
    Code Review
    llvm/lib/Target/AMDGPU/GCNSubtarget.h:1
    @@ -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 {

      bool isFullSIMDMode() const { return !hasSupportsWGP() || !EnableCuMode; }
    

    chinmaydd chinmaydd commented on code on Sep 15, 2026 02:58 UTC
    Code Review
    llvm/lib/Target/AMDGPU/GCNSubtarget.h:1
    @@ -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;
       }

    shiltian shiltian commented on code on Sep 15, 2026 03:14 UTC
    Code Review
    llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll:1
    @@ -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.

    Yeah, I actually wondered what kind of mode before gfx10? How many SIMDs does a target support?

    chinmaydd chinmaydd commented on code on Sep 15, 2026 03:40 UTC
    Code Review
    llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll:1
    @@ -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.

    Looks like before gfx10 there is no selectable CU/WGP execution mode. A pre-gfx10 CU contains four SIMDs, and a work-group's waves can run across all four.

    But the +cumode selects the two-SIMD mode (what we are calling half-SIMD) on targets with WGP support (gfx10+)

    Matt wanted to entirely remove the cumode feature

    chinmaydd chinmaydd commented on code on Sep 15, 2026 03:41 UTC
    Code Review
    llvm/test/CodeGen/AMDGPU/lds-limit-diagnostics.ll:1
    @@ -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.

    This is all too confusing...

    Reviewers
    Assignees
    chinmaydd chinmaydd
    Labels
    risk: low confidence: 76.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 76.9% · Lower = rushed or shallow review
    76.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 9.9% · Safe to merge
    9.9%