brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.3 KiB · a33255a Raw
152 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 22; RUN: llc -mtriple=amdgcn--amdpal -mcpu=gfx803 < %s | FileCheck -check-prefix=GCN %s3 4; Where the mask of lanes wanting to exit the loop on this iteration is not5; obviously already masked by exec (in this case, the xor with -1 inserted by6; control flow annotation), then lower control flow must insert an S_AND_B647; with exec.8 9define void @needs_and(i32 %arg) {10; GCN-LABEL: needs_and:11; GCN:       ; %bb.0: ; %entry12; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)13; GCN-NEXT:    s_mov_b32 s10, 114; GCN-NEXT:    s_mov_b64 s[6:7], 015; GCN-NEXT:    s_branch .LBB0_216; GCN-NEXT:  .LBB0_1: ; %endif17; GCN-NEXT:    ; in Loop: Header=BB0_2 Depth=118; GCN-NEXT:    s_or_b64 exec, exec, s[8:9]19; GCN-NEXT:    s_and_b64 s[4:5], exec, vcc20; GCN-NEXT:    s_or_b64 s[6:7], s[4:5], s[6:7]21; GCN-NEXT:    s_add_i32 s10, s10, 122; GCN-NEXT:    s_andn2_b64 exec, exec, s[6:7]23; GCN-NEXT:    s_cbranch_execz .LBB0_424; GCN-NEXT:  .LBB0_2: ; %loop25; GCN-NEXT:    ; =>This Inner Loop Header: Depth=126; GCN-NEXT:    v_cmp_gt_u32_e64 s[4:5], s10, v027; GCN-NEXT:    v_cmp_le_u32_e32 vcc, s10, v028; GCN-NEXT:    s_and_saveexec_b64 s[8:9], s[4:5]29; GCN-NEXT:    s_cbranch_execz .LBB0_130; GCN-NEXT:  ; %bb.3: ; %then31; GCN-NEXT:    ; in Loop: Header=BB0_2 Depth=132; GCN-NEXT:    s_nop 133; GCN-NEXT:    buffer_store_dword v0, off, s[4:7], s434; GCN-NEXT:    s_branch .LBB0_135; GCN-NEXT:  .LBB0_4: ; %loopexit36; GCN-NEXT:    s_or_b64 exec, exec, s[6:7]37; GCN-NEXT:    s_waitcnt vmcnt(0)38; GCN-NEXT:    s_setpc_b64 s[30:31]39entry:40  br label %loop41 42loop:43  %tmp23phi = phi i32 [ %tmp23, %endif ], [ 0, %entry ]44  %tmp23 = add nuw i32 %tmp23phi, 145  %tmp27 = icmp ult i32 %arg, %tmp2346  br i1 %tmp27, label %then, label %endif47 48then:                                             ; preds = %bb49  call void @llvm.amdgcn.raw.ptr.buffer.store.f32(float poison, ptr addrspace(8) poison, i32 0, i32 poison, i32 0)50  br label %endif51 52endif:                                             ; preds = %bb28, %bb53  br i1 %tmp27, label %loop, label %loopexit54 55loopexit:56  ret void57}58 59; Where the mask of lanes wanting to exit the loop on this iteration is60; obviously already masked by exec (a V_CMP), then lower control flow can omit61; the S_AND_B64 to avoid an unnecessary instruction.62 63define void @doesnt_need_and(i32 %arg) {64; GCN-LABEL: doesnt_need_and:65; GCN:       ; %bb.0: ; %entry66; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)67; GCN-NEXT:    buffer_store_dword v0, off, s[4:7], s468; GCN-NEXT:    s_mov_b32 s6, 069; GCN-NEXT:    s_mov_b64 s[4:5], 070; GCN-NEXT:  .LBB1_1: ; %loop71; GCN-NEXT:    ; =>This Inner Loop Header: Depth=172; GCN-NEXT:    s_add_i32 s6, s6, 173; GCN-NEXT:    v_cmp_le_u32_e32 vcc, s6, v074; GCN-NEXT:    s_or_b64 s[4:5], vcc, s[4:5]75; GCN-NEXT:    s_andn2_b64 exec, exec, s[4:5]76; GCN-NEXT:    s_cbranch_execnz .LBB1_177; GCN-NEXT:  ; %bb.2: ; %loopexit78; GCN-NEXT:    s_or_b64 exec, exec, s[4:5]79; GCN-NEXT:    s_waitcnt vmcnt(0)80; GCN-NEXT:    s_setpc_b64 s[30:31]81entry:82  br label %loop83 84loop:85  %tmp23phi = phi i32 [ %tmp23, %loop ], [ 0, %entry ]86  %tmp23 = add nuw i32 %tmp23phi, 187  %tmp27 = icmp ult i32 %arg, %tmp2388  call void @llvm.amdgcn.raw.ptr.buffer.store.f32(float poison, ptr addrspace(8) poison, i32 0, i32 poison, i32 0)89  br i1 %tmp27, label %loop, label %loopexit90 91loopexit:92  ret void93}94 95; Another case where the mask of lanes wanting to exit the loop is not masked96; by exec, because it is a function parameter.97 98define void @break_cond_is_arg(i32 %arg, i1 %breakcond) {99; GCN-LABEL: break_cond_is_arg:100; GCN:       ; %bb.0: ; %entry101; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)102; GCN-NEXT:    v_and_b32_e32 v1, 1, v1103; GCN-NEXT:    v_cmp_ne_u32_e32 vcc, 1, v1104; GCN-NEXT:    s_mov_b32 s10, 1105; GCN-NEXT:    s_mov_b64 s[6:7], 0106; GCN-NEXT:    s_branch .LBB2_2107; GCN-NEXT:  .LBB2_1: ; %endif108; GCN-NEXT:    ; in Loop: Header=BB2_2 Depth=1109; GCN-NEXT:    s_or_b64 exec, exec, s[8:9]110; GCN-NEXT:    s_and_b64 s[4:5], exec, vcc111; GCN-NEXT:    s_or_b64 s[6:7], s[4:5], s[6:7]112; GCN-NEXT:    s_add_i32 s10, s10, 1113; GCN-NEXT:    s_andn2_b64 exec, exec, s[6:7]114; GCN-NEXT:    s_cbranch_execz .LBB2_4115; GCN-NEXT:  .LBB2_2: ; %loop116; GCN-NEXT:    ; =>This Inner Loop Header: Depth=1117; GCN-NEXT:    v_cmp_gt_u32_e64 s[4:5], s10, v0118; GCN-NEXT:    s_and_saveexec_b64 s[8:9], s[4:5]119; GCN-NEXT:    s_cbranch_execz .LBB2_1120; GCN-NEXT:  ; %bb.3: ; %then121; GCN-NEXT:    ; in Loop: Header=BB2_2 Depth=1122; GCN-NEXT:    s_nop 2123; GCN-NEXT:    buffer_store_dword v0, off, s[4:7], s4124; GCN-NEXT:    s_branch .LBB2_1125; GCN-NEXT:  .LBB2_4: ; %loopexit126; GCN-NEXT:    s_or_b64 exec, exec, s[6:7]127; GCN-NEXT:    s_waitcnt vmcnt(0)128; GCN-NEXT:    s_setpc_b64 s[30:31]129entry:130  br label %loop131 132loop:133  %tmp23phi = phi i32 [ %tmp23, %endif ], [ 0, %entry ]134  %tmp23 = add nuw i32 %tmp23phi, 1135  %tmp27 = icmp ult i32 %arg, %tmp23136  br i1 %tmp27, label %then, label %endif137 138then:                                             ; preds = %bb139  call void @llvm.amdgcn.raw.ptr.buffer.store.f32(float poison, ptr addrspace(8) poison, i32 0, i32 poison, i32 0)140  br label %endif141 142endif:                                             ; preds = %bb28, %bb143  br i1 %breakcond, label %loop, label %loopexit144 145loopexit:146  ret void147}148 149declare void @llvm.amdgcn.raw.ptr.buffer.store.f32(float, ptr addrspace(8), i32, i32, i32 immarg) #0150 151attributes #0 = { nounwind writeonly }152