blob: faa468c974c0829afaf8aa06dbb65d3928b9d55a [file] [log] [blame]
Matt Arsenault58ddad52016-06-10 00:18:41 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
Matt Arsenault22096252016-06-20 18:34:00 +00003declare i1 @llvm.amdgcn.class.f32(float, i32)
4
5; Produces error after adding an implicit def to v_cndmask_b32
Matt Arsenault58ddad52016-06-10 00:18:41 +00006
7; GCN-LABEL: {{^}}vcc_shrink_vcc_def:
Matt Arsenault5d8eb252016-09-30 01:50:20 +00008; GCN: v_cmp_eq_u32_e64 vcc, s{{[0-9]+}}, 0{{$}}
Matt Arsenault58ddad52016-06-10 00:18:41 +00009; GCN: v_cndmask_b32_e32 v{{[0-9]+}}, 1.0, v{{[0-9]+}}, vcc
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000010define amdgpu_kernel void @vcc_shrink_vcc_def(float %arg, i32 %arg1, float %arg2, i32 %arg3) {
Matt Arsenault58ddad52016-06-10 00:18:41 +000011bb0:
12 %tmp = icmp sgt i32 %arg1, 4
13 %c = icmp eq i32 %arg3, 0
14 %tmp4 = select i1 %c, float %arg, float 1.000000e+00
15 %tmp5 = fcmp ogt float %arg2, 0.000000e+00
16 %tmp6 = fcmp olt float %arg2, 1.000000e+00
17 %tmp7 = fcmp olt float %arg, %tmp4
18 %tmp8 = and i1 %tmp5, %tmp6
19 %tmp9 = and i1 %tmp8, %tmp7
20 br i1 %tmp9, label %bb1, label %bb2
21
22bb1:
23 store volatile i32 0, i32 addrspace(1)* undef
24 br label %bb2
25
26bb2:
27 ret void
28}
Matt Arsenault22096252016-06-20 18:34:00 +000029
30; The undef flag on the condition src must be preserved on the
31; implicit vcc use to avoid verifier errors.
32
33; GCN-LABEL: {{^}}preserve_condition_undef_flag:
34; GCN-NOT: vcc
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000035define amdgpu_kernel void @preserve_condition_undef_flag(float %arg, i32 %arg1, float %arg2) {
Matt Arsenault22096252016-06-20 18:34:00 +000036bb0:
37 %tmp = icmp sgt i32 %arg1, 4
38 %undef = call i1 @llvm.amdgcn.class.f32(float undef, i32 undef)
39 %tmp4 = select i1 %undef, float %arg, float 1.000000e+00
40 %tmp5 = fcmp ogt float %arg2, 0.000000e+00
41 %tmp6 = fcmp olt float %arg2, 1.000000e+00
Sanjay Patel8c0cd772018-11-18 17:36:23 +000042 %tmp7 = fcmp olt float %arg, undef
Matt Arsenault22096252016-06-20 18:34:00 +000043 %tmp8 = and i1 %tmp5, %tmp6
44 %tmp9 = and i1 %tmp8, %tmp7
45 br i1 %tmp9, label %bb1, label %bb2
46
47bb1:
48 store volatile i32 0, i32 addrspace(1)* undef
49 br label %bb2
50
51bb2:
52 ret void
53}