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