1 ; RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck --check-prefix=SI --check-prefix=FUNC %s
2 ; RUN: llc < %s -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs | FileCheck --check-prefix=SI --check-prefix=FUNC %s
4 ; FUNC-LABEL: {{^}}break_inserted_outside_of_loop:
6 ; SI: [[LOOP_LABEL:[A-Z0-9]+]]:
7 ; Lowered break instructin:
9 ; Lowered Loop instruction:
11 ; s_cbranch_execnz [[LOOP_LABEL]]
13 define amdgpu_kernel void @break_inserted_outside_of_loop(i32 addrspace(1)* %out, i32 %a) {
15 %tid = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #0
17 %1 = trunc i32 %0 to i1
21 store i32 0, i32 addrspace(1)* %out
25 br i1 %1, label %ENDLOOP, label %ENDIF
29 ; FUNC-LABEL: {{^}}phi_cond_outside_loop:
31 ; SI: s_mov_b64 [[LEFT:s\[[0-9]+:[0-9]+\]]], 0
32 ; SI: s_mov_b64 [[PHI:s\[[0-9]+:[0-9]+\]]], 0
35 ; SI: v_cmp_eq_u32_e64 [[TMP:s\[[0-9]+:[0-9]+\]]],
36 ; SI: s_and_b64 [[PHI]], [[TMP]], exec
40 ; SI: [[LOOP_LABEL:BB[0-9]+_[0-9]+]]: ; %loop
41 ; SI: s_mov_b64 [[TMP:s\[[0-9]+:[0-9]+\]]], [[LEFT]]
42 ; SI: s_and_b64 [[TMP1:s\[[0-9]+:[0-9]+\]]], exec, [[PHI]]
43 ; SI: s_or_b64 [[LEFT]], [[TMP1]], [[TMP]]
44 ; SI: s_andn2_b64 exec, exec, [[LEFT]]
45 ; SI: s_cbranch_execnz [[LOOP_LABEL]]
48 define amdgpu_kernel void @phi_cond_outside_loop(i32 %b) {
50 %tid = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #0
51 %0 = icmp eq i32 %tid , 0
52 br i1 %0, label %if, label %else
58 %1 = icmp eq i32 %b, 0
62 %2 = phi i1 [0, %if], [%1, %else]
66 br i1 %2, label %exit, label %loop
72 ; FIXME: should emit s_endpgm
73 ; CHECK-LABEL: {{^}}switch_unreachable:
76 define amdgpu_kernel void @switch_unreachable(i32 addrspace(1)* %g, i8 addrspace(3)* %l, i32 %x) nounwind {
78 switch i32 %x, label %sw.default [
93 declare float @llvm.fabs.f32(float) nounwind readnone
95 ; This broke the old AMDIL cfg structurizer
96 ; FUNC-LABEL: {{^}}loop_land_info_assert:
97 ; SI: v_cmp_lt_i32_e64 [[CMP4:s\[[0-9:]+\]]], s{{[0-9]+}}, 4{{$}}
98 ; SI: s_and_b64 [[CMP4M:s\[[0-9]+:[0-9]+\]]], exec, [[CMP4]]
99 ; SI: s_branch [[INFLOOP:BB[0-9]+_[0-9]+]]
101 ; SI: [[CONVEX_EXIT:BB[0-9_]+]]
103 ; SI-NEXT: s_cbranch_vccnz [[ENDPGM:BB[0-9]+_[0-9]+]]
104 ; SI: s_cbranch_vccnz [[INFLOOP]]
107 ; SI: buffer_store_dword
110 ; SI: s_cbranch_vccnz [[CONVEX_EXIT]]
112 ; SI: ; %for.cond.preheader
113 ; SI: s_cbranch_vccz [[ENDPGM]]
117 define amdgpu_kernel void @loop_land_info_assert(i32 %c0, i32 %c1, i32 %c2, i32 %c3, i32 %x, i32 %y, i1 %arg) nounwind {
119 %cmp = icmp sgt i32 %c0, 0
120 br label %while.cond.outer
123 %tmp = load float, float addrspace(1)* undef
127 %cmp1 = icmp slt i32 %c1, 4
128 br i1 %cmp1, label %convex.exit, label %for.cond
131 %or = or i1 %cmp, %cmp1
132 br i1 %or, label %return, label %if.end
135 %tmp3 = call float @llvm.fabs.f32(float %tmp) nounwind readnone
136 %cmp2 = fcmp olt float %tmp3, 0x3E80000000000000
137 br i1 %cmp2, label %if.else, label %while.cond.outer
140 store volatile i32 3, i32 addrspace(1)* undef, align 4
144 %cmp3 = icmp slt i32 %c3, 1000
145 br i1 %cmp3, label %for.body, label %return
148 br i1 %cmp3, label %self.loop, label %if.end.2
151 %or.cond2 = or i1 %cmp3, %arg
152 br i1 %or.cond2, label %return, label %for.cond
161 declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #0
163 attributes #0 = { nounwind readnone }