blob: 84a4c212a529020ff98b3639b38e139bbc15da6d [file] [log] [blame]
Matt Arsenault49459052016-05-21 00:29:40 +00001; RUN: llc -march=amdgcn -mcpu=verde < %s | FileCheck %s
Nicolai Haehnleef160de2016-03-16 20:14:33 +00002
3; Test a simple uniform loop that lives inside non-uniform control flow.
4
Matt Arsenault49459052016-05-21 00:29:40 +00005; CHECK-LABEL: {{^}}test1:
6; CHECK: v_cmp_ne_i32_e32 vcc, 0
7; CHECK: s_and_saveexec_b64
Matt Arsenault57431c92016-08-10 19:11:42 +00008; CHECK-NEXT: s_xor_b64
9; CHECK-NEXT: ; mask branch
10; CHECK-NEXT: s_cbranch_execz
11
12; CHECK-NEXT: BB{{[0-9]+_[0-9]+}}: ; %loop_body.preheader
Matt Arsenault49459052016-05-21 00:29:40 +000013
14; CHECK: [[LOOP_BODY_LABEL:BB[0-9]+_[0-9]+]]:
15; CHECK: s_and_b64 vcc, exec, vcc
16; CHECK: s_cbranch_vccz [[LOOP_BODY_LABEL]]
17
18; CHECK: s_endpgm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000019define amdgpu_ps void @test1(<8 x i32> inreg %rsrc, <2 x i32> %addr.base, i32 %y, i32 %p) {
Nicolai Haehnleef160de2016-03-16 20:14:33 +000020main_body:
21 %cc = icmp eq i32 %p, 0
22 br i1 %cc, label %out, label %loop_body
23
24loop_body:
25 %counter = phi i32 [ 0, %main_body ], [ %incr, %loop_body ]
26
27 ; Prevent the loop from being optimized out
28 call void asm sideeffect "", "" ()
29
30 %incr = add i32 %counter, 1
31 %lc = icmp sge i32 %incr, 1000
32 br i1 %lc, label %out, label %loop_body
33
34out:
35 ret void
36}
37
Matt Arsenault57431c92016-08-10 19:11:42 +000038; CHECK-LABEL: {{^}}test2:
39; CHECK: s_and_saveexec_b64
40; CHECK-NEXT: s_xor_b64
41; CHECK-NEXT: ; mask branch
42; CHECK-NEXT: s_cbranch_execz
Tom Stellard92339e82016-03-21 18:56:58 +000043define void @test2(i32 addrspace(1)* %out, i32 %a, i32 %b) {
44main_body:
45 %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
46 %cc = icmp eq i32 %tid, 0
47 br i1 %cc, label %done1, label %if
48
49if:
50 %cmp = icmp eq i32 %a, 0
51 br i1 %cmp, label %done0, label %loop_body
52
53loop_body:
54 %counter = phi i32 [ 0, %if ], [0, %done0], [ %incr, %loop_body ]
55
56 ; Prevent the loop from being optimized out
57 call void asm sideeffect "", "" ()
58
59 %incr = add i32 %counter, 1
60 %lc = icmp sge i32 %incr, 1000
61 br i1 %lc, label %done1, label %loop_body
62
63done0:
64 %cmp0 = icmp eq i32 %b, 0
65 br i1 %cmp0, label %done1, label %loop_body
66
67done1:
68 ret void
69}
70
71declare i32 @llvm.amdgcn.workitem.id.x() #1
72
Nicolai Haehnleef160de2016-03-16 20:14:33 +000073attributes #1 = { nounwind readonly }