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=tonga < %s | FileCheck -check-prefix=GCN -check-prefix=VI -check-prefix=ALL %s
3
4; ALL-LABEL: {{^}}large_alloca_pixel_shader:
5; GCN: s_mov_b32 s8, SCRATCH_RSRC_DWORD0
6; GCN: s_mov_b32 s9, SCRATCH_RSRC_DWORD1
7; GCN: s_mov_b32 s10, -1
8; CI: s_mov_b32 s11, 0x80f000
9; VI: s_mov_b32 s11, 0x800000
10
11; GCN: buffer_store_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s1 offen
12; GCN: buffer_load_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s1 offen
13
14; ALL: ; ScratchSize: 32772
15define void @large_alloca_pixel_shader(i32 %x, i32 %y) #1 {
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: s_mov_b32 s8, SCRATCH_RSRC_DWORD0
27; GCN: s_mov_b32 s9, SCRATCH_RSRC_DWORD1
28; GCN: s_mov_b32 s10, -1
29; CI: s_mov_b32 s11, 0x80f000
30; VI: s_mov_b32 s11, 0x800000
31
32; GCN: buffer_store_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s1 offen
33; GCN: buffer_load_dword {{v[0-9]+}}, {{v[0-9]+}}, s[8:11], s1 offen
34
35; ALL: ; ScratchSize: 32772
36define void @large_alloca_pixel_shader_inreg(i32 inreg %x, i32 inreg %y) #1 {
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  }
47attributes #1 = { nounwind "ShaderType"="0" }
48