[InstCombine] Signed saturation patterns
[llvm-core.git] / test / CodeGen / AMDGPU / call-skip.ll
blobcd963df6c499c768c2641d061a8e54c39af1998a
1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii < %s | FileCheck -enable-var-scope -check-prefix=GCN %s
3 ; A call should be skipped if all lanes are zero, since we don't know
4 ; what side effects should be avoided inside the call.
5 define hidden void @func() #1 {
6   ret void
9 ; GCN-LABEL: {{^}}if_call:
10 ; GCN: s_and_saveexec_b64
11 ; GCN-NEXT: ; mask branch [[END:BB[0-9]+_[0-9]+]]
12 ; GCN-NEXT: s_cbranch_execz [[END]]
13 ; GCN: s_swappc_b64
14 ; GCN: [[END]]:
15 define void @if_call(i32 %flag) #0 {
16   %cc = icmp eq i32 %flag, 0
17   br i1 %cc, label %call, label %end
19 call:
20   call void @func()
21   br label %end
23 end:
24   ret void
27 ; GCN-LABEL: {{^}}if_asm:
28 ; GCN: s_and_saveexec_b64
29 ; GCN-NEXT: ; mask branch [[END:BB[0-9]+_[0-9]+]]
30 ; GCN-NEXT: s_cbranch_execz [[END]]
31 ; GCN: ; sample asm
32 ; GCN: [[END]]:
33 define void @if_asm(i32 %flag) #0 {
34   %cc = icmp eq i32 %flag, 0
35   br i1 %cc, label %call, label %end
37 call:
38   call void asm sideeffect "; sample asm", ""()
39   br label %end
41 end:
42   ret void
45 ; GCN-LABEL: {{^}}if_call_kernel:
46 ; GCN: s_and_saveexec_b64
47 ; GCN-NEXT: ; mask branch [[END:BB[0-9]+_[0-9]+]]
48 ; GCN-NEXT: s_cbranch_execz [[END]]
49 ; GCN: s_swappc_b64
50 define amdgpu_kernel void @if_call_kernel() #0 {
51   %id = call i32 @llvm.amdgcn.workitem.id.x()
52   %cc = icmp eq i32 %id, 0
53   br i1 %cc, label %call, label %end
55 call:
56   call void @func()
57   br label %end
59 end:
60   ret void
63 declare i32 @llvm.amdgcn.workitem.id.x() #2
65 attributes #0 = { nounwind }
66 attributes #1 = { nounwind noinline }
67 attributes #2 = { nounwind readnone speculatable }