1; RUN: llc -march=amdgcn -mcpu=verde -verify-machineinstrs < %s | FileCheck %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck %s
3
4; CHECK-LABEL: {{^}}else_no_execfix:
5; CHECK: ; %Flow
6; CHECK-NEXT: s_or_saveexec_b64 [[DST:s\[[0-9]+:[0-9]+\]]],
7; CHECK-NEXT: s_xor_b64 exec, exec, [[DST]]
8define amdgpu_ps float @else_no_execfix(i32 %z, float %v) #0 {
9main_body:
10  %cc = icmp sgt i32 %z, 5
11  br i1 %cc, label %if, label %else
12
13if:
14  %v.if = fmul float %v, 2.0
15  br label %end
16
17else:
18  %v.else = fmul float %v, 3.0
19  br label %end
20
21end:
22  %r = phi float [ %v.if, %if ], [ %v.else, %else ]
23  ret float %r
24}
25
26; CHECK-LABEL: {{^}}else_execfix_leave_wqm:
27; CHECK: ; %bb.0:
28; CHECK-NEXT: s_mov_b64 [[INIT_EXEC:s\[[0-9]+:[0-9]+\]]], exec
29; CHECK: ; %Flow
30; CHECK-NEXT: s_or_saveexec_b64 [[DST:s\[[0-9]+:[0-9]+\]]],
31; CHECK-NEXT: s_and_b64 exec, exec, [[INIT_EXEC]]
32; CHECK-NEXT: s_and_b64 [[AND_INIT:s\[[0-9]+:[0-9]+\]]], exec, [[DST]]
33; CHECK-NEXT: s_xor_b64 exec, exec, [[AND_INIT]]
34; CHECK-NEXT: s_cbranch_execz
35define amdgpu_ps void @else_execfix_leave_wqm(i32 %z, float %v) #0 {
36main_body:
37  %cc = icmp sgt i32 %z, 5
38  br i1 %cc, label %if, label %else
39
40if:
41  %v.if = fmul float %v, 2.0
42  br label %end
43
44else:
45  %c = fmul float %v, 3.0
46  %tex = call <4 x float> @llvm.amdgcn.image.sample.1d.v4f32.f32(i32 15, float %c, <8 x i32> undef, <4 x i32> undef, i1 0, i32 0, i32 0)
47  %v.else = extractelement <4 x float> %tex, i32 0
48  br label %end
49
50end:
51  %r = phi float [ %v.if, %if ], [ %v.else, %else ]
52  call void @llvm.amdgcn.raw.buffer.store.f32(float %r, <4 x i32> undef, i32 0, i32 0, i32 0)
53  ret void
54}
55
56declare void @llvm.amdgcn.raw.buffer.store.f32(float, <4 x i32>, i32, i32, i32 immarg) #1
57declare <4 x float> @llvm.amdgcn.image.sample.1d.v4f32.f32(i32 immarg, float, <8 x i32>, <4 x i32>, i1 immarg, i32 immarg, i32 immarg) #2
58
59attributes #0 = { nounwind }
60attributes #1 = { nounwind writeonly }
61attributes #2 = { nounwind readonly }
62