[llvm] [SelectionDAG] Let ComputeKnownSignBits handle (shl (ext X), C) (PR #97695)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 08:23:19 PDT 2024
================
@@ -4615,12 +4615,28 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
Tmp = std::min<uint64_t>(Tmp + *ShAmt, VTBits);
return Tmp;
case ISD::SHL:
- if (std::optional<uint64_t> ShAmt =
- getValidMaximumShiftAmount(Op, DemandedElts, Depth + 1)) {
+ if (std::optional<ConstantRange> ShAmtRange =
+ getValidShiftAmountRange(Op, DemandedElts, Depth + 1)) {
+ uint64_t MaxShAmt = ShAmtRange->getUnsignedMax().getZExtValue();
+ uint64_t MinShAmt = ShAmtRange->getUnsignedMin().getZExtValue();
+ if (ISD::isExtOpcode(Op.getOperand(0).getOpcode())) {
+ SDValue Ext = Op.getOperand(0);
+ EVT ExtVT = Ext.getValueType();
+ SDValue Extendee = Ext.getOperand(0);
+ EVT ExtendeeVT = Extendee.getValueType();
+ uint64_t SizeDifference =
+ ExtVT.getScalarSizeInBits() - ExtendeeVT.getScalarSizeInBits();
+ if (SizeDifference <= MinShAmt) {
----------------
RKSimon wrote:
Add a explanation comment (similar to the patch summary)
https://github.com/llvm/llvm-project/pull/97695
More information about the llvm-commits
mailing list