[llvm] 7ad3649 - AMDGPU: Fix alignment for dynamic allocas
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 1 10:06:50 PDT 2020
Author: Matt Arsenault
Date: 2020-06-01T13:06:37-04:00
New Revision: 7ad36491cadee1ed91e18215c30328a3d5c104f9
URL: https://github.com/llvm/llvm-project/commit/7ad36491cadee1ed91e18215c30328a3d5c104f9
DIFF: https://github.com/llvm/llvm-project/commit/7ad36491cadee1ed91e18215c30328a3d5c104f9.diff
LOG: AMDGPU: Fix alignment for dynamic allocas
The alignment value also needs to be scaled by the wave size.
Added:
Modified:
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index bbd3737d2ef0..08effeea1812 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3126,9 +3126,12 @@ SDValue SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(
unsigned StackAlign = TFL->getStackAlignment();
Tmp1 = DAG.getNode(Opc, dl, VT, SP, ScaledSize); // Value
- if (Align > StackAlign)
- Tmp1 = DAG.getNode(ISD::AND, dl, VT, Tmp1,
- DAG.getConstant(-(uint64_t)Align, dl, VT));
+ if (Align > StackAlign) {
+ Tmp1 = DAG.getNode(
+ ISD::AND, dl, VT, Tmp1,
+ DAG.getConstant(-(uint64_t)Align << ST.getWavefrontSizeLog2(), dl, VT));
+ }
+
Chain = DAG.getCopyToReg(Chain, dl, SPReg, Tmp1); // Output chain
Tmp2 = DAG.getCALLSEQ_END(
Chain, DAG.getIntPtrConstant(0, dl, true),
diff --git a/llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll b/llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll
index 060d66ae8428..0cd60bd8203e 100644
--- a/llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll
+++ b/llvm/test/CodeGen/AMDGPU/non-entry-alloca.ll
@@ -95,7 +95,7 @@ define amdgpu_kernel void @kernel_non_entry_block_static_alloca_uniformly_reache
; GCN-NEXT: s_cbranch_scc1 BB1_2
; GCN-NEXT: ; %bb.1: ; %bb.0
; GCN-NEXT: s_add_i32 s6, s32, 0x1000
-; GCN-NEXT: s_andn2_b32 s6, s6, 63
+; GCN-NEXT: s_and_b32 s6, s6, 0xfffff000
; GCN-NEXT: s_lshl_b32 s7, s7, 2
; GCN-NEXT: s_mov_b32 s32, s6
; GCN-NEXT: v_mov_b32_e32 v2, s6
@@ -223,7 +223,7 @@ define void @func_non_entry_block_static_alloca_align64(i32 addrspace(1)* %out,
; GCN-NEXT: s_cbranch_execz BB3_2
; GCN-NEXT: ; %bb.1: ; %bb.0
; GCN-NEXT: s_add_i32 s6, s32, 0x1000
-; GCN-NEXT: s_andn2_b32 s6, s6, 63
+; GCN-NEXT: s_and_b32 s6, s6, 0xfffff000
; GCN-NEXT: v_mov_b32_e32 v2, 0
; GCN-NEXT: v_mov_b32_e32 v5, s6
; GCN-NEXT: v_mov_b32_e32 v6, 1
More information about the llvm-commits
mailing list