[TargetLowering] Add SimplifyMultipleUseDemandedBits 'all elements' helper wrapper. NFC.

This commit is contained in:
Simon Pilgrim 2020-02-18 16:52:01 +00:00
parent 36f480f22c
commit d6eef0614f
3 changed files with 25 additions and 13 deletions

View File

@ -3239,7 +3239,7 @@ public:
/// Helper wrapper around SimplifyDemandedBits.
/// Adds Op back to the worklist upon success.
bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedMask,
bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits,
DAGCombinerInfo &DCI) const;
/// More limited version of SimplifyDemandedBits that can be used to "look
@ -3250,6 +3250,12 @@ public:
SelectionDAG &DAG,
unsigned Depth) const;
/// Helper wrapper around SimplifyMultipleUseDemandedBits, demanding all
/// elements.
SDValue SimplifyMultipleUseDemandedBits(SDValue Op, const APInt &DemandedBits,
SelectionDAG &DAG,
unsigned Depth = 0) const;
/// Look at Vector Op. At this point, we know that only the DemandedElts
/// elements of the result of Op are ever used downstream. If we can use
/// this information to simplify Op, create a new simplified DAG node and
@ -3284,6 +3290,7 @@ public:
const APInt &DemandedElts,
const SelectionDAG &DAG,
unsigned Depth = 0) const;
/// Determine which of the bits specified in Mask are known to be either zero
/// or one and return them in the KnownZero/KnownOne bitsets. The DemandedElts
/// argument allows us to only collect the known bits that are shared by the

View File

@ -790,6 +790,17 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
return SDValue();
}
SDValue TargetLowering::SimplifyMultipleUseDemandedBits(
SDValue Op, const APInt &DemandedBits, SelectionDAG &DAG,
unsigned Depth) const {
EVT VT = Op.getValueType();
APInt DemandedElts = VT.isVector()
? APInt::getAllOnesValue(VT.getVectorNumElements())
: APInt(1, 1);
return SimplifyMultipleUseDemandedBits(Op, DemandedBits, DemandedElts, DAG,
Depth);
}
/// Look at Op. At this point, we know that only the OriginalDemandedBits of the
/// result of Op are ever used downstream. If we can use this information to
/// simplify Op, create a new simplified DAG node and return true, returning the

View File

@ -38426,15 +38426,10 @@ static SDValue combineVSelectToBLENDV(SDNode *N, SelectionDAG &DAG,
}
// Otherwise we can still at least try to simplify multiple use bits.
APInt DemandedMask(APInt::getSignMask(BitWidth));
APInt DemandedElts(APInt::getAllOnesValue(VT.getVectorNumElements()));
KnownBits Known;
TargetLowering::TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
!DCI.isBeforeLegalizeOps());
if (SDValue V = TLI.SimplifyMultipleUseDemandedBits(Cond, DemandedMask,
DemandedElts, DAG, 0))
return DAG.getNode(X86ISD::BLENDV, SDLoc(N), N->getValueType(0),
V, N->getOperand(1), N->getOperand(2));
APInt DemandedBits(APInt::getSignMask(BitWidth));
if (SDValue V = TLI.SimplifyMultipleUseDemandedBits(Cond, DemandedBits, DAG))
return DAG.getNode(X86ISD::BLENDV, SDLoc(N), N->getValueType(0), V,
N->getOperand(1), N->getOperand(2));
return SDValue();
}
@ -42184,9 +42179,8 @@ static SDValue combineMaskedStore(SDNode *N, SelectionDAG &DAG,
APInt DemandedBits(APInt::getSignMask(VT.getScalarSizeInBits()));
if (TLI.SimplifyDemandedBits(Mask, DemandedBits, DCI))
return SDValue(N, 0);
APInt DemandedElts = APInt::getAllOnesValue(VT.getVectorNumElements());
if (SDValue NewMask = TLI.SimplifyMultipleUseDemandedBits(
Mask, DemandedBits, DemandedElts, DAG, 0))
if (SDValue NewMask =
TLI.SimplifyMultipleUseDemandedBits(Mask, DemandedBits, DAG))
return DAG.getMaskedStore(Mst->getChain(), SDLoc(N), Mst->getValue(),
Mst->getBasePtr(), Mst->getOffset(), NewMask,
Mst->getMemoryVT(), Mst->getMemOperand(),