1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -O2 -tail-dup-size=1000 -tail-dup-placement-threshold=1000 -enable-tail-merge=0 < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
3 ; Need to to trigger tail duplication this during
4 ; MachineBlockPlacement, since calls aren't tail duplicated pre-RA.
6 declare void @nonconvergent_func() #0
7 declare void @convergent_func() #1
8 declare void @llvm.amdgcn.s.barrier() #1
9 declare void @llvm.amdgcn.ds.gws.init(i32, i32) #2
10 declare void @llvm.amdgcn.ds.gws.barrier(i32, i32) #2
11 declare void @llvm.amdgcn.ds.gws.sema.release.all(i32 %offset) #2
13 ; barrier shouldn't be duplicated.
15 ; GCN-LABEL: {{^}}taildup_barrier:
18 define void @taildup_barrier(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond) #0 {
20 br i1 %cond, label %bb1, label %bb2
23 store i32 0, ptr addrspace(1) %a
27 store i32 1, ptr addrspace(1) %a
31 call void @llvm.amdgcn.s.barrier()
38 ; GCN-LABEL: {{^}}taildup_convergent_call:
40 ; GCN-NOT: s_swappc_b64
41 define void @taildup_convergent_call(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond) #1 {
43 br i1 %cond, label %bb1, label %bb2
46 store i32 0, ptr addrspace(1) %a
50 store i32 1, ptr addrspace(1) %a
54 call void @convergent_func()
61 ; TODO: Currently there is only one convergent call pseudo, but this
62 ; theoretically could use a nonconvergent variant.
63 ; GCN-LABEL: {{^}}taildup_nonconvergent_call:
65 ; GCN-NOT: s_swappc_b64
66 define void @taildup_nonconvergent_call(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond) #1 {
68 br i1 %cond, label %bb1, label %bb2
71 store i32 0, ptr addrspace(1) %a
75 store i32 1, ptr addrspace(1) %a
79 call void @nonconvergent_func()
86 ; GCN-LABEL: {{^}}taildup_convergent_tailcall:
88 ; GCN-NOT: s_setpc_b64
89 define void @taildup_convergent_tailcall(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond) #1 {
91 br i1 %cond, label %bb1, label %bb2
94 store i32 0, ptr addrspace(1) %a
98 store i32 1, ptr addrspace(1) %a
102 tail call void @convergent_func()
106 ; GCN-LABEL: {{^}}taildup_gws_init:
108 ; GCN-NOT: ds_gws_init
109 define amdgpu_kernel void @taildup_gws_init(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond, i32 %val, i32 %offset) #0 {
111 br i1 %cond, label %bb1, label %bb2
114 store i32 0, ptr addrspace(1) %a
118 store i32 1, ptr addrspace(1) %a
122 call void @llvm.amdgcn.ds.gws.init(i32 %val, i32 %offset)
129 ; GCN-LABEL: {{^}}taildup_gws_barrier:
130 ; GCN: ds_gws_barrier
131 ; GCN-NOT: ds_gws_barrier
132 define amdgpu_kernel void @taildup_gws_barrier(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond, i32 %val, i32 %offset) #0 {
134 br i1 %cond, label %bb1, label %bb2
137 store i32 0, ptr addrspace(1) %a
141 store i32 1, ptr addrspace(1) %a
145 call void @llvm.amdgcn.ds.gws.barrier(i32 %val, i32 %offset)
152 ; GCN-LABEL: {{^}}taildup_gws_sema_release_all:
153 ; GCN: ds_gws_sema_release_all
155 define amdgpu_kernel void @taildup_gws_sema_release_all(ptr addrspace(1) %a, ptr addrspace(1) %b, i1 %cond, i32 %offset) #0 {
157 br i1 %cond, label %bb1, label %bb2
160 store i32 0, ptr addrspace(1) %a
164 store i32 1, ptr addrspace(1) %a
168 call void @llvm.amdgcn.ds.gws.sema.release.all(i32 %offset)
175 attributes #0 = { nounwind }
176 attributes #1 = { nounwind convergent }
177 attributes #2 = { convergent inaccessiblememonly nounwind }