[DAGCombiner] Eliminate dead stores to stack.
[llvm-complete.git] / test / CodeGen / AMDGPU / nested-calls.ll
blob7fbcb9706a891a5e4f5cfa4dcdb9828f4bc7373b
1 ; RUN: llc -march=amdgcn -mcpu=fiji -mattr=-flat-for-global -amdgpu-sroa=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=VI %s
2 ; RUN: llc -march=amdgcn -mcpu=hawaii -amdgpu-sroa=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=CI %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global -amdgpu-sroa=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=GCN -check-prefix=GFX9 -check-prefix=VI %s
5 ; Test calls when called by other callable functions rather than
6 ; kernels.
8 declare void @external_void_func_i32(i32) #0
10 ; GCN-LABEL: {{^}}test_func_call_external_void_func_i32_imm:
11 ; GCN: s_waitcnt
12 ; GCN: s_mov_b32 s5, s32
13 ; Spill CSR VGPR used for SGPR spilling
14 ; GCN: buffer_store_dword v32, off, s[0:3], s5 offset:4
15 ; GCN-DAG: s_add_u32 s32, s32, 0x400
16 ; GCN-DAG: v_writelane_b32 v32, s33, 0
17 ; GCN-DAG: v_writelane_b32 v32, s34, 1
18 ; GCN-DAG: v_writelane_b32 v32, s35, 2
20 ; GCN: s_swappc_b64
22 ; GCN: v_readlane_b32 s35, v32, 2
23 ; GCN: v_readlane_b32 s34, v32, 1
24 ; GCN: v_readlane_b32 s33, v32, 0
25 ; GCN: buffer_load_dword v32, off, s[0:3], s5 offset:4
26 ; GCN: s_sub_u32 s32, s32, 0x400
27 ; GCN: s_setpc_b64
28 define void @test_func_call_external_void_func_i32_imm() #0 {
29   call void @external_void_func_i32(i32 42)
30   ret void
33 ; GCN-LABEL: {{^}}test_func_call_external_void_func_i32_imm_stack_use:
34 ; GCN: s_waitcnt
35 ; GCN: s_mov_b32 s5, s32
36 ; GCN-DAG: s_add_u32 s32, s32, 0x1400{{$}}
37 ; GCN-DAG: buffer_store_dword v{{[0-9]+}}, off, s[0:3], s5 offset
38 ; GCN: s_swappc_b64
39 ; GCN: s_sub_u32 s32, s32, 0x1400{{$}}
40 ; GCN: s_setpc_b64
41 define void @test_func_call_external_void_func_i32_imm_stack_use() #0 {
42   %alloca = alloca [16 x i32], align 4, addrspace(5)
43   %gep0 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 0
44   %gep15 = getelementptr inbounds [16 x i32], [16 x i32] addrspace(5)* %alloca, i32 0, i32 16
45   store volatile i32 0, i32 addrspace(5)* %gep0
46   store volatile i32 0, i32 addrspace(5)* %gep15
47   call void @external_void_func_i32(i32 42)
48   ret void
51 attributes #0 = { nounwind }
52 attributes #1 = { nounwind readnone }
53 attributes #2 = { nounwind noinline }