llvm.org GIT mirror llvm / 8830176
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 Hans Wennborg 4 years ago
3 changed file(s) with 69 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
11331133 MachineFunction *MF = BB->getParent();
11341134 SIMachineFunctionInfo *MFI = MF->getInfo();
11351135 DebugLoc DL = MI.getDebugLoc();
1136 BuildMI(*BB, MI, DL, TII->get(AMDGPU::S_MOVK_I32))
1137 .addOperand(MI.getOperand(0))
1138 .addImm(MFI->LDSSize);
1136 BuildMI(*BB, MI, DL, TII->get(AMDGPU::S_MOV_B32))
1137 .addOperand(MI.getOperand(0))
1138 .addImm(MFI->LDSSize);
11391139 MI.eraseFromParent();
11401140 return BB;
11411141 }
+0
-56
test/CodeGen/AMDGPU/llvm.amdgcn.groupstaticgroup.ll less more
None ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck %s
1 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck %s
2 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
3
4
5 @lds0 = addrspace(3) global [512 x float] undef, align 4
6 @lds1 = addrspace(3) global [256 x float] undef, align 4
7
8 ; FUNC-LABEL: {{^}}groupstaticsize_test0:
9 ; CHECK: s_movk_i32 s{{[0-9]+}}, 0x800
10 define void @get_groupstaticsize_test0(float addrspace(1)* %out, i32 addrspace(1)* %lds_size) #0 {
11 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
12 %idx.0 = add nsw i32 %tid.x, 64
13 %static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
14 store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
15 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
16 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
17 store float %val0, float addrspace(1)* %out, align 4
18
19 ret void
20 }
21
22
23 ; FUNC-LABEL: {{^}}groupstaticsize_test1:
24 ; CHECK: s_movk_i32 s{{[0-9]+}}, 0xc00
25 define void @groupstaticsize_test1(float addrspace(1)* %out, i32 %cond, i32 addrspace(1)* %lds_size) {
26 entry:
27 %static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
28 store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
29 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
30 %idx.0 = add nsw i32 %tid.x, 64
31 %tmp = icmp eq i32 %cond, 0
32 br i1 %tmp, label %if, label %else
33
34 if: ; preds = %entry
35 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
36 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
37 store float %val0, float addrspace(1)* %out, align 4
38 br label %endif
39
40 else: ; preds = %entry
41 %arrayidx1 = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @lds1, i32 0, i32 %idx.0
42 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
43 store float %val1, float addrspace(1)* %out, align 4
44 br label %endif
45
46 endif: ; preds = %else, %if
47 ret void
48 }
49
50
51 declare i32 @llvm.amdgcn.groupstaticsize() #1
52 declare i32 @llvm.amdgcn.workitem.id.x() #1
53
54 attributes #0 = { nounwind }
55 attributes #1 = { nounwind readnone }
0 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck %s
1 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck %s
2 ; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
3
4 @lds0 = addrspace(3) global [512 x float] undef, align 4
5 @lds1 = addrspace(3) global [256 x float] undef, align 4
6
7 @large = addrspace(3) global [4096 x i32] undef, align 4
8
9 ; CHECK-LABEL: {{^}}groupstaticsize_test0:
10 ; CHECK: v_mov_b32_e32 v{{[0-9]+}}, 0x800{{$}}
11 define void @groupstaticsize_test0(float addrspace(1)* %out, i32 addrspace(1)* %lds_size) #0 {
12 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
13 %idx.0 = add nsw i32 %tid.x, 64
14 %static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
15 store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
16 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
17 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
18 store float %val0, float addrspace(1)* %out, align 4
19
20 ret void
21 }
22
23 ; CHECK-LABEL: {{^}}groupstaticsize_test1:
24 ; CHECK: v_mov_b32_e32 v{{[0-9]+}}, 0xc00{{$}}
25 define void @groupstaticsize_test1(float addrspace(1)* %out, i32 %cond, i32 addrspace(1)* %lds_size) {
26 entry:
27 %static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
28 store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
29 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
30 %idx.0 = add nsw i32 %tid.x, 64
31 %tmp = icmp eq i32 %cond, 0
32 br i1 %tmp, label %if, label %else
33
34 if: ; preds = %entry
35 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
36 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
37 store float %val0, float addrspace(1)* %out, align 4
38 br label %endif
39
40 else: ; preds = %entry
41 %arrayidx1 = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @lds1, i32 0, i32 %idx.0
42 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
43 store float %val1, float addrspace(1)* %out, align 4
44 br label %endif
45
46 endif: ; preds = %else, %if
47 ret void
48 }
49
50 ; Exceeds 16-bit simm limit of s_movk_i32
51 ; CHECK-LABEL: {{^}}large_groupstaticsize:
52 ; CHECK: v_mov_b32_e32 [[REG:v[0-9]+]], 0x4000{{$}}
53 define void @large_groupstaticsize(i32 addrspace(1)* %size, i32 %idx) #0 {
54 %gep = getelementptr inbounds [4096 x i32], [4096 x i32] addrspace(3)* @large, i32 0, i32 %idx
55 store volatile i32 0, i32 addrspace(3)* %gep
56 %static_lds_size = call i32 @llvm.amdgcn.groupstaticsize()
57 store i32 %static_lds_size, i32 addrspace(1)* %size
58 ret void
59 }
60
61 declare i32 @llvm.amdgcn.groupstaticsize() #1
62 declare i32 @llvm.amdgcn.workitem.id.x() #1
63
64 attributes #0 = { nounwind }
65 attributes #1 = { nounwind readnone }