Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 8830176

Browse files
committed
Merging r275928 and r276438:
------------------------------------------------------------------------ r275928 | arsenm | 2016-07-18 16:09:51 -0700 (Mon, 18 Jul 2016) | 1 line AMDGPU: Fix test name and broken CHECK-LABEL ------------------------------------------------------------------------ ------------------------------------------------------------------------ r276438 | arsenm | 2016-07-22 10:01:33 -0700 (Fri, 22 Jul 2016) | 6 lines AMDGPU: Fix groupstaticsize for large LDS The size can exceed s_movk_i32's limit, and we don't want to use it this early since it inhibits optimizations. This should probably be merged to the release branch. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@276664 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 065c539 commit 8830176

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,9 @@ MachineBasicBlock *SITargetLowering::EmitInstrWithCustomInserter(
11341134
MachineFunction *MF = BB->getParent();
11351135
SIMachineFunctionInfo *MFI = MF->getInfo<SIMachineFunctionInfo>();
11361136
DebugLoc DL = MI.getDebugLoc();
1137-
BuildMI(*BB, MI, DL, TII->get(AMDGPU::S_MOVK_I32))
1138-
.addOperand(MI.getOperand(0))
1139-
.addImm(MFI->LDSSize);
1137+
BuildMI(*BB, MI, DL, TII->get(AMDGPU::S_MOV_B32))
1138+
.addOperand(MI.getOperand(0))
1139+
.addImm(MFI->LDSSize);
11401140
MI.eraseFromParent();
11411141
return BB;
11421142
}

test/CodeGen/AMDGPU/llvm.amdgcn.groupstaticgroup.ll renamed to test/CodeGen/AMDGPU/llvm.amdgcn.groupstaticsize.ll

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck %s
33
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
44

5-
65
@lds0 = addrspace(3) global [512 x float] undef, align 4
76
@lds1 = addrspace(3) global [256 x float] undef, align 4
87

9-
; FUNC-LABEL: {{^}}groupstaticsize_test0:
10-
; CHECK: s_movk_i32 s{{[0-9]+}}, 0x800
11-
define void @get_groupstaticsize_test0(float addrspace(1)* %out, i32 addrspace(1)* %lds_size) #0 {
8+
@large = addrspace(3) global [4096 x i32] undef, align 4
9+
10+
; CHECK-LABEL: {{^}}groupstaticsize_test0:
11+
; CHECK: v_mov_b32_e32 v{{[0-9]+}}, 0x800{{$}}
12+
define void @groupstaticsize_test0(float addrspace(1)* %out, i32 addrspace(1)* %lds_size) #0 {
1213
%tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
1314
%idx.0 = add nsw i32 %tid.x, 64
1415
%static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
@@ -20,9 +21,8 @@ define void @get_groupstaticsize_test0(float addrspace(1)* %out, i32 addrspace(1
2021
ret void
2122
}
2223

23-
24-
; FUNC-LABEL: {{^}}groupstaticsize_test1:
25-
; CHECK: s_movk_i32 s{{[0-9]+}}, 0xc00
24+
; CHECK-LABEL: {{^}}groupstaticsize_test1:
25+
; CHECK: v_mov_b32_e32 v{{[0-9]+}}, 0xc00{{$}}
2626
define void @groupstaticsize_test1(float addrspace(1)* %out, i32 %cond, i32 addrspace(1)* %lds_size) {
2727
entry:
2828
%static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
@@ -48,6 +48,16 @@ endif: ; preds = %else, %if
4848
ret void
4949
}
5050

51+
; Exceeds 16-bit simm limit of s_movk_i32
52+
; CHECK-LABEL: {{^}}large_groupstaticsize:
53+
; CHECK: v_mov_b32_e32 [[REG:v[0-9]+]], 0x4000{{$}}
54+
define void @large_groupstaticsize(i32 addrspace(1)* %size, i32 %idx) #0 {
55+
%gep = getelementptr inbounds [4096 x i32], [4096 x i32] addrspace(3)* @large, i32 0, i32 %idx
56+
store volatile i32 0, i32 addrspace(3)* %gep
57+
%static_lds_size = call i32 @llvm.amdgcn.groupstaticsize()
58+
store i32 %static_lds_size, i32 addrspace(1)* %size
59+
ret void
60+
}
5161

5262
declare i32 @llvm.amdgcn.groupstaticsize() #1
5363
declare i32 @llvm.amdgcn.workitem.id.x() #1

0 commit comments

Comments
 (0)