blob: 2ca3aeba0b1d2f452bc2cc389baae38da23af1cb [file] [log] [blame]
Tom Stellardd4a19502015-04-14 14:36:45 +00001; 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 -verify-machineinstrs | FileCheck --check-prefix=SI --check-prefix=FUNC %s
3
4; FUNC-LABEL: {{^}}break_inserted_outside_of_loop:
5
6; SI: [[LOOP_LABEL:[A-Z0-9]+]]:
7; Lowered break instructin:
8; SI: s_or_b64
9; Lowered Loop instruction:
10; SI: s_andn2_b64
11; s_cbranch_execnz [[LOOP_LABEL]]
12; SI: s_endpgm
Tom Stellardbc4497b2016-02-12 23:45:29 +000013define void @break_inserted_outside_of_loop(i32 addrspace(1)* %out, i32 %a) {
Tom Stellardd4a19502015-04-14 14:36:45 +000014main_body:
Tom Stellardbc4497b2016-02-12 23:45:29 +000015 %tid = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #0
16 %0 = and i32 %a, %tid
Tom Stellardd4a19502015-04-14 14:36:45 +000017 %1 = trunc i32 %0 to i1
18 br label %ENDIF
19
20ENDLOOP:
21 store i32 0, i32 addrspace(1)* %out
22 ret void
23
24ENDIF:
25 br i1 %1, label %ENDLOOP, label %ENDIF
26}
Tom Stellard0b7feb12015-05-01 03:44:08 +000027
28
29; FUNC-LABEL: {{^}}phi_cond_outside_loop:
30; FIXME: This could be folded into the s_or_b64 instruction
31; SI: s_mov_b64 [[ZERO:s\[[0-9]+:[0-9]+\]]], 0
32; SI: [[LOOP_LABEL:[A-Z0-9]+]]
33; SI: v_cmp_ne_i32_e32 vcc, 0, v{{[0-9]+}}
34
35; SI_IF_BREAK instruction:
36; SI: s_or_b64 [[BREAK:s\[[0-9]+:[0-9]+\]]], vcc, [[ZERO]]
37
38; SI_LOOP instruction:
39; SI: s_andn2_b64 exec, exec, [[BREAK]]
40; SI: s_cbranch_execnz [[LOOP_LABEL]]
41; SI: s_endpgm
42
Tom Stellardbc4497b2016-02-12 23:45:29 +000043define void @phi_cond_outside_loop(i32 %b) {
Tom Stellard0b7feb12015-05-01 03:44:08 +000044entry:
Tom Stellardbc4497b2016-02-12 23:45:29 +000045 %tid = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #0
46 %0 = icmp eq i32 %tid , 0
Tom Stellard0b7feb12015-05-01 03:44:08 +000047 br i1 %0, label %if, label %else
48
49if:
50 br label %endif
51
52else:
53 %1 = icmp eq i32 %b, 0
54 br label %endif
55
56endif:
57 %2 = phi i1 [0, %if], [%1, %else]
58 br label %loop
59
60loop:
61 br i1 %2, label %exit, label %loop
62
63exit:
64 ret void
65}
Tom Stellardbc4497b2016-02-12 23:45:29 +000066
67declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #0
68
69attributes #0 = { nounwind readnone }