1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI %s
2; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,CI %s
3
4%struct.ByValStruct = type { [4 x i32] }
5; Make sure the offset is folded and function's frame register is used
6; rather than the global scratch wave offset.
7; GCN-LABEL: {{^}}void_func_byval_struct_use_outside_entry_block:
8; GCN-NOT: v_lshrrev_b32
9; GCN-NOT: s_sub_u32
10
11; GCN: s_and_saveexec_b64
12; GCN: s_cbranch_execz [[BB1:BB[0-9]+_[0-9]+]]
13
14; GCN: buffer_load_dword [[LOAD0:v[0-9]+]], off, s[0:3], s32{{$}}
15; GCN-NOT: s32
16; GCN: buffer_store_dword [[LOAD0]], off, s[0:3], s32{{$}}
17; GCN-NOT: s32
18
19; GCN: buffer_load_dword [[LOAD1:v[0-9]+]], off, s[0:3], s32 offset:16{{$}}
20; GCN-NOT: s32
21; GCN: buffer_store_dword [[LOAD1]], off, s[0:3], s32 offset:16{{$}}
22; GCN-NOT: s32
23
24; GCN: [[BB1]]
25; GCN: s_or_b64 exec, exec
26define hidden void @void_func_byval_struct_use_outside_entry_block(%struct.ByValStruct addrspace(5)* byval(%struct.ByValStruct) noalias nocapture align 4 %arg0, %struct.ByValStruct addrspace(5)* byval(%struct.ByValStruct) noalias nocapture align 4 %arg1, i1 %cond) #1 {
27entry:
28  br i1 %cond, label %bb0, label %bb1
29
30bb0:
31  %arrayidx = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg0, i32 0, i32 0, i32 0
32  %tmp = load volatile i32, i32 addrspace(5)* %arrayidx, align 4
33  %add = add nsw i32 %tmp, 1
34  store volatile i32 %add, i32 addrspace(5)* %arrayidx, align 4
35  %arrayidx2 = getelementptr inbounds %struct.ByValStruct, %struct.ByValStruct addrspace(5)* %arg1, i32 0, i32 0, i32 0
36  %tmp1 = load volatile i32, i32 addrspace(5)* %arrayidx2, align 4
37  %add3 = add nsw i32 %tmp1, 2
38  store volatile i32 %add3, i32 addrspace(5)* %arrayidx2, align 4
39  store volatile i32 9, i32 addrspace(1)* null, align 4
40  br label %bb1
41
42bb1:
43  ret void
44}
45declare hidden void @external_void_func_void() #0
46
47declare void @llvm.lifetime.start.p5i8(i64, i8 addrspace(5)* nocapture) #3
48declare void @llvm.lifetime.end.p5i8(i64, i8 addrspace(5)* nocapture) #3
49
50attributes #0 = { nounwind }
51attributes #1 = { noinline norecurse nounwind }
52attributes #2 = { nounwind norecurse "frame-pointer"="all" }
53