blob: 5547bb2a6529bde5d5cbdef0017f123ff33585e5 [file] [log] [blame]
Stanislav Mekhanoshin6c7a8d02017-08-04 06:58:42 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
3; GCN-LABEL: {{^}}if_with_kill:
4; GCN: s_and_saveexec_b64 [[SAVEEXEC:s\[[0-9:]+\]]],
5; GCN-NEXT: s_xor_b64 s[{{[0-9:]+}}], exec, [[SAVEEXEC]]
6define amdgpu_ps void @if_with_kill(i32 %arg) {
7.entry:
8 %cmp = icmp eq i32 %arg, 32
9 br i1 %cmp, label %then, label %endif
10
11then:
Tom Stellarda2be8f42018-04-24 21:37:57 +000012 tail call void @llvm.amdgcn.kill(i1 false)
Stanislav Mekhanoshin6c7a8d02017-08-04 06:58:42 +000013 br label %endif
14
15endif:
16 ret void
17}
18
19; GCN-LABEL: {{^}}if_with_loop_kill_after:
20; GCN: s_and_saveexec_b64 [[SAVEEXEC:s\[[0-9:]+\]]],
21; GCN-NEXT: s_xor_b64 s[{{[0-9:]+}}], exec, [[SAVEEXEC]]
22define amdgpu_ps void @if_with_loop_kill_after(i32 %arg) {
23.entry:
24 %cmp = icmp eq i32 %arg, 32
25 br i1 %cmp, label %then, label %endif
26
27then:
28 %sub = sub i32 %arg, 1
29 br label %loop
30
31loop:
32 %ind = phi i32 [%sub, %then], [%dec, %loop]
33 %dec = sub i32 %ind, 1
34 %cc = icmp ne i32 %ind, 0
35 br i1 %cc, label %loop, label %break
36
37break:
Tom Stellarda2be8f42018-04-24 21:37:57 +000038 tail call void @llvm.amdgcn.kill(i1 false)
Stanislav Mekhanoshin6c7a8d02017-08-04 06:58:42 +000039 br label %endif
40
41endif:
42 ret void
43}
44
45; GCN-LABEL: {{^}}if_with_kill_inside_loop:
46; GCN: s_and_saveexec_b64 [[SAVEEXEC:s\[[0-9:]+\]]],
47; GCN-NEXT: s_xor_b64 s[{{[0-9:]+}}], exec, [[SAVEEXEC]]
48define amdgpu_ps void @if_with_kill_inside_loop(i32 %arg) {
49.entry:
50 %cmp = icmp eq i32 %arg, 32
51 br i1 %cmp, label %then, label %endif
52
53then:
54 %sub = sub i32 %arg, 1
55 br label %loop
56
57loop:
58 %ind = phi i32 [%sub, %then], [%dec, %loop]
59 %dec = sub i32 %ind, 1
60 %cc = icmp ne i32 %ind, 0
Tom Stellarda2be8f42018-04-24 21:37:57 +000061 tail call void @llvm.amdgcn.kill(i1 false)
Stanislav Mekhanoshin6c7a8d02017-08-04 06:58:42 +000062 br i1 %cc, label %loop, label %break
63
64break:
65 br label %endif
66
67endif:
68 ret void
69}
70
Tom Stellarda2be8f42018-04-24 21:37:57 +000071declare void @llvm.amdgcn.kill(i1) #0
72
73attributes #0 = { nounwind }