Skip to content

Commit 715bed6

Browse files
committed
[X86] Move IsNOT helper after getTargetConstantBitsFromNode helper. NFC.
A future patch will use getTargetConstantBitsFromNode inside IsNOT.
1 parent 425defd commit 715bed6

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4324,35 +4324,6 @@ static SDValue getBitSelect(const SDLoc &DL, MVT VT, SDValue LHS, SDValue RHS,
43244324
return DAG.getNode(ISD::OR, DL, VT, LHS, RHS);
43254325
}
43264326

4327-
// Match (xor X, -1) -> X.
4328-
// Match extract_subvector(xor X, -1) -> extract_subvector(X).
4329-
// Match concat_vectors(xor X, -1, xor Y, -1) -> concat_vectors(X, Y).
4330-
static SDValue IsNOT(SDValue V, SelectionDAG &DAG) {
4331-
V = peekThroughBitcasts(V);
4332-
if (V.getOpcode() == ISD::XOR &&
4333-
(ISD::isBuildVectorAllOnes(V.getOperand(1).getNode()) ||
4334-
isAllOnesConstant(V.getOperand(1))))
4335-
return V.getOperand(0);
4336-
if (V.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
4337-
(isNullConstant(V.getOperand(1)) || V.getOperand(0).hasOneUse())) {
4338-
if (SDValue Not = IsNOT(V.getOperand(0), DAG)) {
4339-
Not = DAG.getBitcast(V.getOperand(0).getValueType(), Not);
4340-
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(Not), V.getValueType(),
4341-
Not, V.getOperand(1));
4342-
}
4343-
}
4344-
SmallVector<SDValue, 2> CatOps;
4345-
if (collectConcatOps(V.getNode(), CatOps, DAG)) {
4346-
for (SDValue &CatOp : CatOps) {
4347-
SDValue NotCat = IsNOT(CatOp, DAG);
4348-
if (!NotCat) return SDValue();
4349-
CatOp = DAG.getBitcast(CatOp.getValueType(), NotCat);
4350-
}
4351-
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(V), V.getValueType(), CatOps);
4352-
}
4353-
return SDValue();
4354-
}
4355-
43564327
void llvm::createUnpackShuffleMask(EVT VT, SmallVectorImpl<int> &Mask,
43574328
bool Lo, bool Unary) {
43584329
assert(VT.getScalarType().isSimple() && (VT.getSizeInBits() % 128) == 0 &&
@@ -4910,6 +4881,35 @@ static bool getTargetShuffleMaskIndices(SDValue MaskNode,
49104881
return true;
49114882
}
49124883

4884+
// Match (xor X, -1) -> X.
4885+
// Match extract_subvector(xor X, -1) -> extract_subvector(X).
4886+
// Match concat_vectors(xor X, -1, xor Y, -1) -> concat_vectors(X, Y).
4887+
static SDValue IsNOT(SDValue V, SelectionDAG &DAG) {
4888+
V = peekThroughBitcasts(V);
4889+
if (V.getOpcode() == ISD::XOR &&
4890+
(ISD::isBuildVectorAllOnes(V.getOperand(1).getNode()) ||
4891+
isAllOnesConstant(V.getOperand(1))))
4892+
return V.getOperand(0);
4893+
if (V.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
4894+
(isNullConstant(V.getOperand(1)) || V.getOperand(0).hasOneUse())) {
4895+
if (SDValue Not = IsNOT(V.getOperand(0), DAG)) {
4896+
Not = DAG.getBitcast(V.getOperand(0).getValueType(), Not);
4897+
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(Not), V.getValueType(),
4898+
Not, V.getOperand(1));
4899+
}
4900+
}
4901+
SmallVector<SDValue, 2> CatOps;
4902+
if (collectConcatOps(V.getNode(), CatOps, DAG)) {
4903+
for (SDValue &CatOp : CatOps) {
4904+
SDValue NotCat = IsNOT(CatOp, DAG);
4905+
if (!NotCat) return SDValue();
4906+
CatOp = DAG.getBitcast(CatOp.getValueType(), NotCat);
4907+
}
4908+
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(V), V.getValueType(), CatOps);
4909+
}
4910+
return SDValue();
4911+
}
4912+
49134913
/// Create a shuffle mask that matches the PACKSS/PACKUS truncation.
49144914
/// A multi-stage pack shuffle mask is created by specifying NumStages > 1.
49154915
/// Note: This ignores saturation, so inputs must be checked first.

0 commit comments

Comments
 (0)