diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp index e5baffc0f064b2..6e1f188bb3d3de 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp @@ -1181,8 +1181,8 @@ bool AMDGPURegisterBankInfo::applyMappingDynStackAlloc( // Guard in case the stack growth direction ever changes with scratch // instructions. - if (TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsDown) - return false; + assert(TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp && + "Stack grows upwards for AMDGPU"); Register Dst = MI.getOperand(0).getReg(); Register AllocSize = MI.getOperand(1).getReg(); diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 8dfebd36a962e1..7da93f90341d22 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -4041,17 +4041,15 @@ SDValue SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(SDValue Op, Chain = SP.getValue(1); MaybeAlign Alignment = cast(Tmp3)->getMaybeAlignValue(); const TargetFrameLowering *TFL = Subtarget->getFrameLowering(); - unsigned Opc = - TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp - ? ISD::ADD - : ISD::SUB; + assert(TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp && + "Stack grows upwards for AMDGPU"); SDValue ScaledSize = DAG.getNode( ISD::SHL, dl, VT, Size, DAG.getConstant(Subtarget->getWavefrontSizeLog2(), dl, MVT::i32)); Align StackAlign = TFL->getStackAlign(); - Tmp1 = DAG.getNode(Opc, dl, VT, SP, ScaledSize); // Value + Tmp1 = DAG.getNode(ISD::ADD, dl, VT, SP, ScaledSize); // Value if (Alignment && *Alignment > StackAlign) { Tmp1 = DAG.getNode( ISD::AND, dl, VT, Tmp1,