1; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck %s
2; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck %s
3; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck %s
4
5
6@lds0 = addrspace(3) global [512 x float] undef, align 4
7@lds1 = addrspace(3) global [256 x float] undef, align 4
8
9; FUNC-LABEL: {{^}}groupstaticsize_test0:
10; CHECK: s_movk_i32 s{{[0-9]+}}, 0x800
11define void @get_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
24; FUNC-LABEL: {{^}}groupstaticsize_test1:
25; CHECK: s_movk_i32 s{{[0-9]+}}, 0xc00
26define void @groupstaticsize_test1(float addrspace(1)* %out, i32 %cond, i32 addrspace(1)* %lds_size) {
27entry:
28  %static_lds_size = call i32 @llvm.amdgcn.groupstaticsize() #1
29  store i32 %static_lds_size, i32 addrspace(1)* %lds_size, align 4
30  %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
31  %idx.0 = add nsw i32 %tid.x, 64
32  %tmp = icmp eq i32 %cond, 0
33  br i1 %tmp, label %if, label %else
34
35if:                                               ; preds = %entry
36  %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds0, i32 0, i32 %idx.0
37  %val0 = load float, float addrspace(3)* %arrayidx0, align 4
38  store float %val0, float addrspace(1)* %out, align 4
39  br label %endif
40
41else:                                             ; preds = %entry
42  %arrayidx1 = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @lds1, i32 0, i32 %idx.0
43  %val1 = load float, float addrspace(3)* %arrayidx1, align 4
44  store float %val1, float addrspace(1)* %out, align 4
45  br label %endif
46
47endif:                                            ; preds = %else, %if
48  ret void
49}
50
51
52declare i32 @llvm.amdgcn.groupstaticsize() #1
53declare i32 @llvm.amdgcn.workitem.id.x() #1
54
55attributes #0 = { nounwind }
56attributes #1 = { nounwind readnone }
57