[llvm] [AMDGPU] Do not scale private alloca size when using flat-scratch (PR #201142)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 03:40:21 PDT 2026
Juan Manuel Martinez =?utf-8?q?CaamaƱo?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/201142 at github.com>
================
@@ -4694,21 +4698,29 @@ SDValue SITargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
assert(Size.getValueType() == MVT::i32 && "Size must be 32-bit");
SDValue NewSP;
if (isa<ConstantSDNode>(Size)) {
- // For constant sized alloca, scale alloca size by wave-size
- SDValue ScaledSize = DAG.getNode(
- ISD::SHL, dl, VT, Size,
- DAG.getConstant(Subtarget->getWavefrontSizeLog2(), dl, MVT::i32));
+ // Increase the stack pointer by the size of the alloca.
+ // If not using flat-scratch, we have to scale the size by the wave-size.
+ SDValue ScaledSize = Size;
+ if (!HasFlatScratch) {
+ ScaledSize =
+ DAG.getNode(ISD::SHL, dl, VT, Size,
+ DAG.getConstant(WavefrontSizeLog2, dl, MVT::i32));
+ }
----------------
arsenm wrote:
```suggestion
SDValue ScaledSize = HasFlatScratch ? Size :
DAG.getNode(ISD::SHL, dl, VT, Size,
DAG.getConstant(WavefrontSizeLog2, dl, MVT::i32));
```
https://github.com/llvm/llvm-project/pull/201142
More information about the llvm-commits
mailing list