1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s 2; RUN: llc -march=amdgcn -verify-machineinstrs -O0 < %s 3 4; GCN-LABEL: {{^}}test_loop: 5; GCN: [[LABEL:BB[0-9+]_[0-9]+]]: 6; GCN: ds_read_b32 7; GCN: ds_write_b32 8; GCN: s_branch [[LABEL]] 9; GCN: s_endpgm 10define void @test_loop(float addrspace(3)* %ptr, i32 %n) nounwind { 11entry: 12 %cmp = icmp eq i32 %n, -1 13 br i1 %cmp, label %for.exit, label %for.body 14 15for.exit: 16 ret void 17 18for.body: 19 %indvar = phi i32 [ %inc, %for.body ], [ 0, %entry ] 20 %tmp = add i32 %indvar, 32 21 %arrayidx = getelementptr float, float addrspace(3)* %ptr, i32 %tmp 22 %vecload = load float, float addrspace(3)* %arrayidx, align 4 23 %add = fadd float %vecload, 1.0 24 store float %add, float addrspace(3)* %arrayidx, align 8 25 %inc = add i32 %indvar, 1 26 br label %for.body 27} 28 29; GCN-LABEL: @loop_const_true 30; GCN: [[LABEL:BB[0-9+]_[0-9]+]]: 31; GCN: ds_read_b32 32; GCN: ds_write_b32 33; GCN: s_branch [[LABEL]] 34define void @loop_const_true(float addrspace(3)* %ptr, i32 %n) nounwind { 35entry: 36 br label %for.body 37 38for.exit: 39 ret void 40 41for.body: 42 %indvar = phi i32 [ %inc, %for.body ], [ 0, %entry ] 43 %tmp = add i32 %indvar, 32 44 %arrayidx = getelementptr float, float addrspace(3)* %ptr, i32 %tmp 45 %vecload = load float, float addrspace(3)* %arrayidx, align 4 46 %add = fadd float %vecload, 1.0 47 store float %add, float addrspace(3)* %arrayidx, align 8 48 %inc = add i32 %indvar, 1 49 br i1 true, label %for.body, label %for.exit 50} 51 52; GCN-LABEL: {{^}}loop_const_false: 53; GCN-NOT: s_branch 54; GCN: s_endpgm 55define void @loop_const_false(float addrspace(3)* %ptr, i32 %n) nounwind { 56entry: 57 br label %for.body 58 59for.exit: 60 ret void 61 62; XXX - Should there be an S_ENDPGM? 63for.body: 64 %indvar = phi i32 [ %inc, %for.body ], [ 0, %entry ] 65 %tmp = add i32 %indvar, 32 66 %arrayidx = getelementptr float, float addrspace(3)* %ptr, i32 %tmp 67 %vecload = load float, float addrspace(3)* %arrayidx, align 4 68 %add = fadd float %vecload, 1.0 69 store float %add, float addrspace(3)* %arrayidx, align 8 70 %inc = add i32 %indvar, 1 71 br i1 false, label %for.body, label %for.exit 72} 73 74; GCN-LABEL: {{^}}loop_const_undef: 75; GCN-NOT: s_branch 76; GCN: s_endpgm 77define void @loop_const_undef(float addrspace(3)* %ptr, i32 %n) nounwind { 78entry: 79 br label %for.body 80 81for.exit: 82 ret void 83 84; XXX - Should there be an s_endpgm? 85for.body: 86 %indvar = phi i32 [ %inc, %for.body ], [ 0, %entry ] 87 %tmp = add i32 %indvar, 32 88 %arrayidx = getelementptr float, float addrspace(3)* %ptr, i32 %tmp 89 %vecload = load float, float addrspace(3)* %arrayidx, align 4 90 %add = fadd float %vecload, 1.0 91 store float %add, float addrspace(3)* %arrayidx, align 8 92 %inc = add i32 %indvar, 1 93 br i1 undef, label %for.body, label %for.exit 94} 95 96; GCN-LABEL: {{^}}loop_arg_0: 97; GCN: v_and_b32_e32 v{{[0-9]+}}, 1, v{{[0-9]+}} 98; GCN: v_cmp_eq_i32_e32 vcc, 1, 99 100; GCN: s_and_b64 s{{\[[0-9]+:[0-9]+\]}}, exec, vcc 101; GCN: [[LOOPBB:BB[0-9]+_[0-9]+]] 102; GCN: s_cbranch_vccnz [[LOOPBB]] 103; GCN-NEXT: ; BB#2 104; GCN-NEXT: s_endpgm 105define void @loop_arg_0(float addrspace(3)* %ptr, i32 %n, i1 %cond) nounwind { 106entry: 107 br label %for.body 108 109for.exit: 110 ret void 111 112for.body: 113 %indvar = phi i32 [ %inc, %for.body ], [ 0, %entry ] 114 %tmp = add i32 %indvar, 32 115 %arrayidx = getelementptr float, float addrspace(3)* %ptr, i32 %tmp 116 %vecload = load float, float addrspace(3)* %arrayidx, align 4 117 %add = fadd float %vecload, 1.0 118 store float %add, float addrspace(3)* %arrayidx, align 8 119 %inc = add i32 %indvar, 1 120 br i1 %cond, label %for.body, label %for.exit 121} 122