1; RUN: llc -global-isel=0 -amdgpu-fixed-function-abi=0 -mtriple=amdgcn-amd-amdhsa < %s | FileCheck -check-prefixes=GCN,SDAG %s
2; RUN: llc -global-isel=1 -amdgpu-fixed-function-abi=1 -mtriple=amdgcn-amd-amdhsa < %s | FileCheck -check-prefixes=GCN,GISEL %s
3
4; FIXME: Emitting unnecessary flat_scratch setup
5
6; GCN-LABEL: {{^}}test_call_undef:
7; SDAG: s_mov_b32 flat_scratch_lo, s5
8; SDAG: s_add_u32 s4, s4, s7
9; SDAG: s_lshr_b32
10; GCN: s_endpgm
11define amdgpu_kernel void @test_call_undef() #0 {
12  %val = call i32 undef(i32 1)
13  %op = add i32 %val, 1
14  store volatile i32 %op, i32 addrspace(1)* undef
15  ret void
16}
17
18; GCN-LABEL: {{^}}test_tail_call_undef:
19; SDAG: s_waitcnt
20; SDAG-NEXT: .Lfunc_end
21
22; GISEL: s_swappc_b64 s{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}
23define i32 @test_tail_call_undef() #0 {
24  %call = tail call i32 undef(i32 1)
25  ret i32 %call
26}
27
28; GCN-LABEL: {{^}}test_call_null:
29; SDAG: s_mov_b32 flat_scratch_lo, s5
30; SDAG: s_add_u32 s4, s4, s7
31; SDAG: s_lshr_b32
32
33; GISEL: s_swappc_b64 s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
34; GCN: s_endpgm
35define amdgpu_kernel void @test_call_null() #0 {
36  %val = call i32 null(i32 1)
37  %op = add i32 %val, 1
38  store volatile i32 %op, i32 addrspace(1)* null
39  ret void
40}
41
42; GCN-LABEL: {{^}}test_tail_call_null:
43; SDAG: s_waitcnt
44; SDAG-NEXT: .Lfunc_end
45
46; GISEL: s_swappc_b64 s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
47define i32 @test_tail_call_null() #0 {
48  %call = tail call i32 null(i32 1)
49  ret i32 %call
50}
51