1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

AMDGPU: Implement computeKnownBitsForTargetNode for mbcnt

llvm-svn: 318100
This commit is contained in:
Matt Arsenault 2017-11-13 22:55:05 +00:00
parent 5d4ac8cff2
commit 5cd1df1dd6
4 changed files with 38 additions and 2 deletions

View File

@ -4084,6 +4084,20 @@ void AMDGPUTargetLowering::computeKnownBitsForTargetNode(
Known.Zero.setHighBits(32 - MaxValBits);
break;
}
case ISD::INTRINSIC_WO_CHAIN: {
unsigned IID = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
switch (IID) {
case Intrinsic::amdgcn_mbcnt_lo:
case Intrinsic::amdgcn_mbcnt_hi: {
// These return at most the wavefront size - 1.
unsigned Size = Op.getValueType().getSizeInBits();
Known.Zero.setHighBits(Size - Subtarget->getWavefrontSizeLog2());
break;
}
default:
break;
}
}
}
}

View File

@ -228,6 +228,10 @@ public:
return WavefrontSize;
}
unsigned getWavefrontSizeLog2() const {
return Log2_32(WavefrontSize);
}
int getLocalMemorySize() const {
return LocalMemorySize;
}

View File

@ -4,8 +4,8 @@ declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #0
declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #0
; SI-LABEL: {{^}}test_array_ptr_calc:
; SI-DAG: v_mul_lo_i32
; SI-DAG: v_mul_hi_i32
; SI-DAG: v_mul_u32_u24
; SI-DAG: v_mul_hi_u32_u24
; SI: s_endpgm
define amdgpu_kernel void @test_array_ptr_calc(i32 addrspace(1)* noalias %out, [1025 x i32] addrspace(1)* noalias %inA, i32 addrspace(1)* noalias %inB) {
%mbcnt.lo = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0)

View File

@ -14,6 +14,24 @@ main_body:
ret void
}
; GCN-LABEL: {{^}}mbcnt_lo_known_bits:
; GCN: v_mbcnt_lo_u32_b32
; GCN-NOT: and
define i32 @mbcnt_lo_known_bits(i32 %x, i32 %y) #0 {
%lo = call i32 @llvm.amdgcn.mbcnt.lo(i32 %x, i32 %y)
%mask = and i32 %lo, 63
ret i32 %mask
}
; GCN-LABEL: {{^}}mbcnt_hi_known_bits:
; GCN: v_mbcnt_hi_u32_b32
; GCN-NOT: and
define i32 @mbcnt_hi_known_bits(i32 %x, i32 %y) #0 {
%hi = call i32 @llvm.amdgcn.mbcnt.hi(i32 %x, i32 %y)
%mask = and i32 %hi, 63
ret i32 %mask
}
declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #0
declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #0
declare void @llvm.amdgcn.exp.f32(i32, i32, float, float, float, float, i1, i1) #1