mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:50:30 +00:00
[X86] Move BEXTR DemandedBits handling inside SimplifyDemandedBitsForTargetNode
Some prep work for PR39153.
This commit is contained in:
parent
80bf477ac5
commit
1f9f866ff9
@ -36247,6 +36247,30 @@ bool X86TargetLowering::SimplifyDemandedBitsForTargetNode(
|
||||
Known.Zero.setLowBits(NumElts);
|
||||
return false;
|
||||
}
|
||||
case X86ISD::BEXTR: {
|
||||
SDValue Op0 = Op.getOperand(0);
|
||||
SDValue Op1 = Op.getOperand(1);
|
||||
|
||||
// Only bottom 16-bits of the control bits are required.
|
||||
if (auto *Cst1 = dyn_cast<ConstantSDNode>(Op1)) {
|
||||
// NOTE: SimplifyDemandedBits won't do this for constants.
|
||||
const APInt &Val1 = Cst1->getAPIntValue();
|
||||
APInt MaskedVal1 = Val1 & 0xFFFF;
|
||||
if (MaskedVal1 != Val1) {
|
||||
SDLoc DL(Op);
|
||||
return TLO.CombineTo(
|
||||
Op, TLO.DAG.getNode(X86ISD::BEXTR, DL, VT, Op0,
|
||||
TLO.DAG.getConstant(MaskedVal1, DL, VT)));
|
||||
}
|
||||
}
|
||||
|
||||
KnownBits Known1;
|
||||
APInt DemandedMask(APInt::getLowBitsSet(BitWidth, 16));
|
||||
if (SimplifyDemandedBits(Op1, DemandedMask, Known1, TLO, Depth + 1))
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TargetLowering::SimplifyDemandedBitsForTargetNode(
|
||||
@ -43019,27 +43043,15 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
|
||||
static SDValue combineBEXTR(SDNode *N, SelectionDAG &DAG,
|
||||
TargetLowering::DAGCombinerInfo &DCI,
|
||||
const X86Subtarget &Subtarget) {
|
||||
SDValue Op0 = N->getOperand(0);
|
||||
SDValue Op1 = N->getOperand(1);
|
||||
EVT VT = N->getValueType(0);
|
||||
unsigned NumBits = VT.getSizeInBits();
|
||||
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
|
||||
// TODO - Constant Folding.
|
||||
if (auto *Cst1 = dyn_cast<ConstantSDNode>(Op1)) {
|
||||
// Reduce Cst1 to the bottom 16-bits.
|
||||
// NOTE: SimplifyDemandedBits won't do this for constants.
|
||||
const APInt &Val1 = Cst1->getAPIntValue();
|
||||
APInt MaskedVal1 = Val1 & 0xFFFF;
|
||||
if (MaskedVal1 != Val1)
|
||||
return DAG.getNode(X86ISD::BEXTR, SDLoc(N), VT, Op0,
|
||||
DAG.getConstant(MaskedVal1, SDLoc(N), VT));
|
||||
}
|
||||
|
||||
// Only bottom 16-bits of the control bits are required.
|
||||
APInt DemandedMask(APInt::getLowBitsSet(NumBits, 16));
|
||||
if (TLI.SimplifyDemandedBits(Op1, DemandedMask, DCI))
|
||||
// Simplify the inputs.
|
||||
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
|
||||
APInt DemandedMask(APInt::getAllOnesValue(NumBits));
|
||||
if (TLI.SimplifyDemandedBits(SDValue(N, 0), DemandedMask, DCI))
|
||||
return SDValue(N, 0);
|
||||
|
||||
return SDValue();
|
||||
|
Loading…
Reference in New Issue
Block a user