forked from OSchip/llvm-project
[CodeGen] Use DAG.getAllOnesConstant where possible to simplify code. NFC.
This commit is contained in:
parent
124bcc1a13
commit
d51da74889
|
@ -3240,9 +3240,8 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
|
|||
assert(TLI.isOperationLegalOrCustom(ISD::ADD, VT) &&
|
||||
TLI.isOperationLegalOrCustom(ISD::XOR, VT) &&
|
||||
"Don't know how to expand this subtraction!");
|
||||
Tmp1 = DAG.getNode(
|
||||
ISD::XOR, dl, VT, Node->getOperand(1),
|
||||
DAG.getConstant(APInt::getAllOnes(VT.getSizeInBits()), dl, VT));
|
||||
Tmp1 = DAG.getNode(ISD::XOR, dl, VT, Node->getOperand(1),
|
||||
DAG.getAllOnesConstant(dl, VT));
|
||||
Tmp1 = DAG.getNode(ISD::ADD, dl, VT, Tmp1, DAG.getConstant(1, dl, VT));
|
||||
Results.push_back(DAG.getNode(ISD::ADD, dl, VT, Node->getOperand(0), Tmp1));
|
||||
break;
|
||||
|
|
|
@ -943,10 +943,8 @@ SDValue VectorLegalizer::ExpandSELECT(SDNode *Node) {
|
|||
// What is the size of each element in the vector mask.
|
||||
EVT BitTy = MaskTy.getScalarType();
|
||||
|
||||
Mask = DAG.getSelect(
|
||||
DL, BitTy, Mask,
|
||||
DAG.getConstant(APInt::getAllOnes(BitTy.getSizeInBits()), DL, BitTy),
|
||||
DAG.getConstant(0, DL, BitTy));
|
||||
Mask = DAG.getSelect(DL, BitTy, Mask, DAG.getAllOnesConstant(DL, BitTy),
|
||||
DAG.getConstant(0, DL, BitTy));
|
||||
|
||||
// Broadcast the mask so that the entire vector is all one or all zero.
|
||||
if (VT.isFixedLengthVector())
|
||||
|
@ -960,8 +958,7 @@ SDValue VectorLegalizer::ExpandSELECT(SDNode *Node) {
|
|||
Op1 = DAG.getNode(ISD::BITCAST, DL, MaskTy, Op1);
|
||||
Op2 = DAG.getNode(ISD::BITCAST, DL, MaskTy, Op2);
|
||||
|
||||
SDValue AllOnes =
|
||||
DAG.getConstant(APInt::getAllOnes(BitTy.getSizeInBits()), DL, MaskTy);
|
||||
SDValue AllOnes = DAG.getAllOnesConstant(DL, MaskTy);
|
||||
SDValue NotMask = DAG.getNode(ISD::XOR, DL, MaskTy, Mask, AllOnes);
|
||||
|
||||
Op1 = DAG.getNode(ISD::AND, DL, MaskTy, Op1, Mask);
|
||||
|
@ -1207,8 +1204,7 @@ SDValue VectorLegalizer::ExpandVSELECT(SDNode *Node) {
|
|||
Op1 = DAG.getNode(ISD::BITCAST, DL, VT, Op1);
|
||||
Op2 = DAG.getNode(ISD::BITCAST, DL, VT, Op2);
|
||||
|
||||
SDValue AllOnes =
|
||||
DAG.getConstant(APInt::getAllOnes(VT.getScalarSizeInBits()), DL, VT);
|
||||
SDValue AllOnes = DAG.getAllOnesConstant(DL, VT);
|
||||
SDValue NotMask = DAG.getNode(ISD::XOR, DL, VT, Mask, AllOnes);
|
||||
|
||||
Op1 = DAG.getNode(ISD::AND, DL, VT, Op1, Mask);
|
||||
|
@ -1501,10 +1497,9 @@ void VectorLegalizer::UnrollStrictFPOp(SDNode *Node,
|
|||
|
||||
if (Node->getOpcode() == ISD::STRICT_FSETCC ||
|
||||
Node->getOpcode() == ISD::STRICT_FSETCCS)
|
||||
ScalarResult = DAG.getSelect(
|
||||
dl, EltVT, ScalarResult,
|
||||
DAG.getConstant(APInt::getAllOnes(EltVT.getSizeInBits()), dl, EltVT),
|
||||
DAG.getConstant(0, dl, EltVT));
|
||||
ScalarResult = DAG.getSelect(dl, EltVT, ScalarResult,
|
||||
DAG.getAllOnesConstant(dl, EltVT),
|
||||
DAG.getConstant(0, dl, EltVT));
|
||||
|
||||
OpValues.push_back(ScalarResult);
|
||||
OpChains.push_back(ScalarChain);
|
||||
|
@ -1536,10 +1531,8 @@ SDValue VectorLegalizer::UnrollVSETCC(SDNode *Node) {
|
|||
TLI.getSetCCResultType(DAG.getDataLayout(),
|
||||
*DAG.getContext(), TmpEltVT),
|
||||
LHSElem, RHSElem, CC);
|
||||
Ops[i] = DAG.getSelect(
|
||||
dl, EltVT, Ops[i],
|
||||
DAG.getConstant(APInt::getAllOnes(EltVT.getSizeInBits()), dl, EltVT),
|
||||
DAG.getConstant(0, dl, EltVT));
|
||||
Ops[i] = DAG.getSelect(dl, EltVT, Ops[i], DAG.getAllOnesConstant(dl, EltVT),
|
||||
DAG.getConstant(0, dl, EltVT));
|
||||
}
|
||||
return DAG.getBuildVector(VT, dl, Ops);
|
||||
}
|
||||
|
|
|
@ -1347,10 +1347,7 @@ SDValue SelectionDAG::getPtrExtendInReg(SDValue Op, const SDLoc &DL, EVT VT) {
|
|||
|
||||
/// getNOT - Create a bitwise NOT operation as (XOR Val, -1).
|
||||
SDValue SelectionDAG::getNOT(const SDLoc &DL, SDValue Val, EVT VT) {
|
||||
EVT EltVT = VT.getScalarType();
|
||||
SDValue NegOne =
|
||||
getConstant(APInt::getAllOnes(EltVT.getSizeInBits()), DL, VT);
|
||||
return getNode(ISD::XOR, DL, VT, Val, NegOne);
|
||||
return getNode(ISD::XOR, DL, VT, Val, getAllOnesConstant(DL, VT));
|
||||
}
|
||||
|
||||
SDValue SelectionDAG::getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT) {
|
||||
|
|
|
@ -12182,7 +12182,7 @@ static bool isConditionalZeroOrAllOnes(SDNode *N, bool AllOnes,
|
|||
// When looking for a 0 constant, N can be zext or sext.
|
||||
OtherOp = DAG.getConstant(1, dl, VT);
|
||||
else
|
||||
OtherOp = DAG.getConstant(APInt::getAllOnes(VT.getSizeInBits()), dl, VT);
|
||||
OtherOp = DAG.getAllOnesConstant(dl, VT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1400,7 +1400,7 @@ static bool isConditionalZeroOrAllOnes(SDNode *N, bool AllOnes, SDValue &CC,
|
|||
// value is 0.
|
||||
OtherOp = DAG.getConstant(0, dl, VT);
|
||||
else
|
||||
OtherOp = DAG.getConstant(APInt::getAllOnes(VT.getSizeInBits()), dl, VT);
|
||||
OtherOp = DAG.getAllOnesConstant(dl, VT);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41235,7 +41235,7 @@ static SDValue combineMinMaxReduction(SDNode *Extract, SelectionDAG &DAG,
|
|||
else if (BinOp == ISD::SMIN)
|
||||
Mask = DAG.getConstant(APInt::getSignedMinValue(MaskEltsBits), DL, SrcVT);
|
||||
else if (BinOp == ISD::UMAX)
|
||||
Mask = DAG.getConstant(APInt::getAllOnes(MaskEltsBits), DL, SrcVT);
|
||||
Mask = DAG.getAllOnesConstant(DL, SrcVT);
|
||||
|
||||
if (Mask)
|
||||
MinPos = DAG.getNode(ISD::XOR, DL, SrcVT, Mask, MinPos);
|
||||
|
|
Loading…
Reference in New Issue