forked from OSchip/llvm-project
[X86] Moved IsNOT helper earlier. NFCI.
Makes it available for more combines to use without adding declarations. llvm-svn: 367436
This commit is contained in:
parent
c4fa139a5c
commit
0707f66ad0
|
@ -5799,6 +5799,34 @@ static SDValue getExtendInVec(unsigned Opcode, const SDLoc &DL, EVT VT,
|
|||
return DAG.getNode(Opcode, DL, VT, In);
|
||||
}
|
||||
|
||||
// Match (xor X, -1) -> X.
|
||||
// Match extract_subvector(xor X, -1) -> extract_subvector(X).
|
||||
// Match concat_vectors(xor X, -1, xor Y, -1) -> concat_vectors(X, Y).
|
||||
static SDValue IsNOT(SDValue V, SelectionDAG &DAG) {
|
||||
V = peekThroughBitcasts(V);
|
||||
if (V.getOpcode() == ISD::XOR &&
|
||||
ISD::isBuildVectorAllOnes(V.getOperand(1).getNode()))
|
||||
return V.getOperand(0);
|
||||
if (V.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
|
||||
(isNullConstant(V.getOperand(1)) || V.getOperand(0).hasOneUse())) {
|
||||
if (SDValue Not = IsNOT(V.getOperand(0), DAG)) {
|
||||
Not = DAG.getBitcast(V.getOperand(0).getValueType(), Not);
|
||||
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(Not), V.getValueType(),
|
||||
Not, V.getOperand(1));
|
||||
}
|
||||
}
|
||||
SmallVector<SDValue, 2> CatOps;
|
||||
if (collectConcatOps(V.getNode(), CatOps)) {
|
||||
for (SDValue &CatOp : CatOps) {
|
||||
SDValue NotCat = IsNOT(CatOp, DAG);
|
||||
if (!NotCat) return SDValue();
|
||||
CatOp = DAG.getBitcast(CatOp.getValueType(), NotCat);
|
||||
}
|
||||
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(V), V.getValueType(), CatOps);
|
||||
}
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
/// Returns a vector_shuffle node for an unpackl operation.
|
||||
static SDValue getUnpackl(SelectionDAG &DAG, const SDLoc &dl, MVT VT,
|
||||
SDValue V1, SDValue V2) {
|
||||
|
@ -38229,34 +38257,6 @@ static SDValue combineCompareEqual(SDNode *N, SelectionDAG &DAG,
|
|||
return SDValue();
|
||||
}
|
||||
|
||||
// Match (xor X, -1) -> X.
|
||||
// Match extract_subvector(xor X, -1) -> extract_subvector(X).
|
||||
// Match concat_vectors(xor X, -1, xor Y, -1) -> concat_vectors(X, Y).
|
||||
static SDValue IsNOT(SDValue V, SelectionDAG &DAG) {
|
||||
V = peekThroughBitcasts(V);
|
||||
if (V.getOpcode() == ISD::XOR &&
|
||||
ISD::isBuildVectorAllOnes(V.getOperand(1).getNode()))
|
||||
return V.getOperand(0);
|
||||
if (V.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
|
||||
(isNullConstant(V.getOperand(1)) || V.getOperand(0).hasOneUse())) {
|
||||
if (SDValue Not = IsNOT(V.getOperand(0), DAG)) {
|
||||
Not = DAG.getBitcast(V.getOperand(0).getValueType(), Not);
|
||||
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, SDLoc(Not), V.getValueType(),
|
||||
Not, V.getOperand(1));
|
||||
}
|
||||
}
|
||||
SmallVector<SDValue, 2> CatOps;
|
||||
if (collectConcatOps(V.getNode(), CatOps)) {
|
||||
for (SDValue &CatOp : CatOps) {
|
||||
SDValue NotCat = IsNOT(CatOp, DAG);
|
||||
if (!NotCat) return SDValue();
|
||||
CatOp = DAG.getBitcast(CatOp.getValueType(), NotCat);
|
||||
}
|
||||
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(V), V.getValueType(), CatOps);
|
||||
}
|
||||
return SDValue();
|
||||
}
|
||||
|
||||
/// Try to fold: (and (xor X, -1), Y) -> (andnp X, Y).
|
||||
static SDValue combineANDXORWithAllOnesIntoANDNP(SDNode *N, SelectionDAG &DAG) {
|
||||
assert(N->getOpcode() == ISD::AND);
|
||||
|
|
Loading…
Reference in New Issue