[llvm] [AMDGPU] Simplify, fix and improve known bits for mbcnt (PR #104768)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 06:27:16 PDT 2024
================
@@ -15758,16 +15758,12 @@ void SITargetLowering::computeKnownBitsForTargetNode(const SDValue Op,
case Intrinsic::amdgcn_mbcnt_hi: {
const GCNSubtarget &ST =
DAG.getMachineFunction().getSubtarget<GCNSubtarget>();
- // These return at most the (wavefront size - 1) + src1
- // As long as src1 is an immediate we can calc known bits
- KnownBits Src1Known = DAG.computeKnownBits(Op.getOperand(2), Depth + 1);
- unsigned Src1ValBits = Src1Known.countMaxActiveBits();
- unsigned MaxActiveBits = std::max(Src1ValBits, ST.getWavefrontSizeLog2());
- // Cater for potential carry
- MaxActiveBits += Src1ValBits ? 1 : 0;
- unsigned Size = Op.getValueType().getSizeInBits();
- if (MaxActiveBits < Size)
- Known.Zero.setHighBits(Size - MaxActiveBits);
+ // Wave64 mbcnt_lo returns at most 32 + src1. Otherwise these return at
+ // most 31 + src1.
+ Known.Zero.setHighBits(
+ ST.isWave64() && IID == Intrinsic::amdgcn_mbcnt_lo ? 26 : 27);
----------------
jayfoad wrote:
It would have to be:
`32 - (IID == Intrinsic::amdgcn_mbcnt_lo ? ST.getWavefrontSizeLog2() : 5)`
https://github.com/llvm/llvm-project/pull/104768
More information about the llvm-commits
mailing list