1; RUN: llc -march=amdgcn -mcpu=bonaire < %s | FileCheck -check-prefix=GCN -check-prefix=CI -check-prefix=ALL %s
2; RUN: llc -march=amdgcn -mcpu=carrizo < %s | FileCheck -check-prefix=GCN -check-prefix=VI -check-prefix=ALL %s
3
4; ALL-LABEL: {{^}}large_alloca_pixel_shader:
5; GCN-DAG: s_mov_b32 s8, SCRATCH_RSRC_DWORD0
6; GCN-DAG: s_mov_b32 s9, SCRATCH_RSRC_DWORD1
7; GCN-DAG: s_mov_b32 s10, -1
8; CI-DAG: s_mov_b32 s11, 0xe8f000
9; VI-DAG: s_mov_b32 s11, 0xe80000
10
11; GCN: buffer_store_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s0 offen
12; GCN: buffer_load_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s0 offen
13
14; ALL: ; ScratchSize: 32772
15define amdgpu_ps void @large_alloca_pixel_shader(i32 %x, i32 %y) #0 {
16  %large = alloca [8192 x i32], align 4
17  %gep = getelementptr [8192 x i32], [8192 x i32]* %large, i32 0, i32 8191
18  store volatile i32 %x, i32* %gep
19  %gep1 = getelementptr [8192 x i32], [8192 x i32]* %large, i32 0, i32 %y
20  %val = load volatile i32, i32* %gep1
21  store volatile i32 %val, i32 addrspace(1)* undef
22  ret void
23}
24
25; ALL-LABEL: {{^}}large_alloca_pixel_shader_inreg:
26; GCN-DAG: s_mov_b32 s8, SCRATCH_RSRC_DWORD0
27; GCN-DAG: s_mov_b32 s9, SCRATCH_RSRC_DWORD1
28; GCN-DAG: s_mov_b32 s10, -1
29; CI-DAG: s_mov_b32 s11, 0xe8f000
30; VI-DAG: s_mov_b32 s11, 0xe80000
31
32; GCN: buffer_store_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s2 offen
33; GCN: buffer_load_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s2 offen
34
35; ALL: ; ScratchSize: 32772
36define amdgpu_ps void @large_alloca_pixel_shader_inreg(i32 inreg %x, i32 inreg %y) #0 {
37  %large = alloca [8192 x i32], align 4
38  %gep = getelementptr [8192 x i32], [8192 x i32]* %large, i32 0, i32 8191
39  store volatile i32 %x, i32* %gep
40  %gep1 = getelementptr [8192 x i32], [8192 x i32]* %large, i32 0, i32 %y
41  %val = load volatile i32, i32* %gep1
42  store volatile i32 %val, i32 addrspace(1)* undef
43  ret void
44}
45
46attributes #0 = { nounwind  }
47