[llvm] [InstCombine] Remove shl if we only demand known signbits of shift source (PR #79014)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 23:31:13 PDT 2024
================
@@ -655,25 +655,31 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
}
}
- // TODO: If we only want bits that already match the signbit then we don't
+ // We only want bits that already match the signbit then we don't
// need to shift.
+ uint64_t ShiftAmt = SA->getLimitedValue(BitWidth - 1);
+ if (DemandedMask.countr_zero() >= ShiftAmt) {
+ unsigned NumHiDemandedBits = BitWidth - DemandedMask.countr_zero();
+ unsigned SignBits =
+ ComputeNumSignBits(I->getOperand(0), Depth + 1, CxtI);
----------------
ParkHanbum wrote:
@goldsteinn I understand!
https://github.com/llvm/llvm-project/pull/79014
More information about the llvm-commits
mailing list