145 lines · plain
1; RUN: llc -mtriple=amdgcn--amdpal -mcpu=verde < %s | FileCheck -check-prefix=GCN %s2; RUN: llc -mtriple=amdgcn--amdpal -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=GCN %s3 4; GCN-LABEL: {{^}}fold_mi_v_and_0:5; GCN: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}}6; GCN-NOT: [[RESULT]]7; GCN: buffer_store_dword [[RESULT]]8define amdgpu_kernel void @fold_mi_v_and_0(ptr addrspace(1) %out) {9 %x = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #010 %size = call i32 @llvm.amdgcn.groupstaticsize()11 %and = and i32 %size, %x12 store i32 %and, ptr addrspace(1) %out13 ret void14}15 16; GCN-LABEL: {{^}}fold_mi_s_and_0:17; GCN: v_mov_b32_e32 [[RESULT:v[0-9]+]], 0{{$}}18; GCN-NOT: [[RESULT]]19; GCN: buffer_store_dword [[RESULT]]20define amdgpu_kernel void @fold_mi_s_and_0(ptr addrspace(1) %out, i32 %x) #0 {21 %size = call i32 @llvm.amdgcn.groupstaticsize()22 %and = and i32 %size, %x23 store i32 %and, ptr addrspace(1) %out24 ret void25}26 27; GCN-LABEL: {{^}}fold_mi_v_or_0:28; GCN: v_mbcnt_lo_u32_b32{{(_e64)*}} [[RESULT:v[0-9]+]]29; GCN-NOT: [[RESULT]]30; GCN: buffer_store_dword [[RESULT]]31define amdgpu_kernel void @fold_mi_v_or_0(ptr addrspace(1) %out) {32 %x = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #033 %size = call i32 @llvm.amdgcn.groupstaticsize()34 %or = or i32 %size, %x35 store i32 %or, ptr addrspace(1) %out36 ret void37}38 39; GCN-LABEL: {{^}}fold_mi_s_or_0:40; GCN: s_load_dword [[SVAL:s[0-9]+]]41; GCN-NOT: [[SVAL]]42; GCN: v_mov_b32_e32 [[VVAL:v[0-9]+]], [[SVAL]]43; GCN-NOT: [[VVAL]]44; GCN: buffer_store_dword [[VVAL]]45define amdgpu_kernel void @fold_mi_s_or_0(ptr addrspace(1) %out, i32 %x) #0 {46 %size = call i32 @llvm.amdgcn.groupstaticsize()47 %or = or i32 %size, %x48 store i32 %or, ptr addrspace(1) %out49 ret void50}51 52; GCN-LABEL: {{^}}fold_mi_v_xor_0:53; GCN: v_mbcnt_lo_u32_b32{{(_e64)*}} [[RESULT:v[0-9]+]]54; GCN-NOT: [[RESULT]]55; GCN: buffer_store_dword [[RESULT]]56define amdgpu_kernel void @fold_mi_v_xor_0(ptr addrspace(1) %out) {57 %x = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #058 %size = call i32 @llvm.amdgcn.groupstaticsize()59 %xor = xor i32 %size, %x60 store i32 %xor, ptr addrspace(1) %out61 ret void62}63 64; GCN-LABEL: {{^}}fold_mi_s_xor_0:65; GCN: s_load_dword [[SVAL:s[0-9]+]]66; GCN-NOT: [[SVAL]]67; GCN: v_mov_b32_e32 [[VVAL:v[0-9]+]], [[SVAL]]68; GCN-NOT: [[VVAL]]69; GCN: buffer_store_dword [[VVAL]]70define amdgpu_kernel void @fold_mi_s_xor_0(ptr addrspace(1) %out, i32 %x) #0 {71 %size = call i32 @llvm.amdgcn.groupstaticsize()72 %xor = xor i32 %size, %x73 store i32 %xor, ptr addrspace(1) %out74 ret void75}76 77; GCN-LABEL: {{^}}fold_mi_s_not_0:78; GCN: v_mov_b32_e32 [[RESULT:v[0-9]+]], -1{{$}}79; GCN-NOT: [[RESULT]]80; GCN: buffer_store_dword [[RESULT]]81define amdgpu_kernel void @fold_mi_s_not_0(ptr addrspace(1) %out, i32 %x) #0 {82 %size = call i32 @llvm.amdgcn.groupstaticsize()83 %xor = xor i32 %size, -184 store i32 %xor, ptr addrspace(1) %out85 ret void86}87 88; GCN-LABEL: {{^}}fold_mi_v_not_0:89; GCN: v_bcnt_u32_b32{{(_e64)*}} v[[RESULT_LO:[0-9]+]], v{{[0-9]+}}, 0{{$}}90; GCN: v_bcnt_u32_b32{{(_e32)*(_e64)*}} v[[RESULT_LO:[0-9]+]], v{{[0-9]+}}, v[[RESULT_LO]]{{$}}91; GCN-NEXT: v_not_b32_e32 v[[RESULT_LO]]92; GCN-NEXT: v_mov_b32_e32 v[[RESULT_HI:[0-9]+]], -1{{$}}93; GCN-NEXT: buffer_store_dwordx2 v[[[RESULT_LO]]:[[RESULT_HI]]]94define amdgpu_kernel void @fold_mi_v_not_0(ptr addrspace(1) %out) {95 %vreg = load volatile i64, ptr addrspace(1) poison96 %ctpop = call i64 @llvm.ctpop.i64(i64 %vreg)97 %xor = xor i64 %ctpop, -198 store i64 %xor, ptr addrspace(1) %out99 ret void100}101 102; The neg1 appears after folding the not 0103; GCN-LABEL: {{^}}fold_mi_or_neg1:104; GCN: buffer_load_dwordx2105; GCN: buffer_load_dwordx2 v[[[VREG1_LO:[0-9]+]]:[[VREG1_HI:[0-9]+]]]106 107; GCN: v_bcnt_u32_b32{{(_e64)*}} v[[RESULT_LO:[0-9]+]], v{{[0-9]+}}, 0{{$}}108; GCN: v_bcnt_u32_b32{{(_e32)*(_e64)*}} v[[RESULT_LO:[0-9]+]], v{{[0-9]+}}, v[[RESULT_LO]]{{$}}109; GCN-DAG: v_not_b32_e32 v[[RESULT_LO]], v[[RESULT_LO]]110; GCN-DAG: v_or_b32_e32 v[[RESULT_LO]], v[[VREG1_LO]], v[[RESULT_LO]]111; GCN-DAG: v_mov_b32_e32 v[[RESULT_HI:[0-9]+]], v[[VREG1_HI]]112; GCN: buffer_store_dwordx2 v[[[RESULT_LO]]:[[RESULT_HI]]]113define amdgpu_kernel void @fold_mi_or_neg1(ptr addrspace(1) %out) {114 %vreg0 = load volatile i64, ptr addrspace(1) poison115 %vreg1 = load volatile i64, ptr addrspace(1) poison116 %ctpop = call i64 @llvm.ctpop.i64(i64 %vreg0)117 %xor = xor i64 %ctpop, -1118 %or = or i64 %xor, %vreg1119 store i64 %or, ptr addrspace(1) %out120 ret void121}122 123; GCN-LABEL: {{^}}fold_mi_and_neg1:124; GCN: v_bcnt_u32_b32125; GCN: v_bcnt_u32_b32126; GCN: v_not_b32127; GCN: v_and_b32128; GCN-NOT: v_and_b32129define amdgpu_kernel void @fold_mi_and_neg1(ptr addrspace(1) %out) {130 %vreg0 = load volatile i64, ptr addrspace(1) poison131 %vreg1 = load volatile i64, ptr addrspace(1) poison132 %ctpop = call i64 @llvm.ctpop.i64(i64 %vreg0)133 %xor = xor i64 %ctpop, -1134 %and = and i64 %xor, %vreg1135 store i64 %and, ptr addrspace(1) %out136 ret void137}138 139declare i64 @llvm.ctpop.i64(i64) #1140declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #1141declare i32 @llvm.amdgcn.groupstaticsize() #1142 143attributes #0 = { nounwind }144attributes #1 = { nounwind readnone }145