@@ -4324,35 +4324,6 @@ static SDValue getBitSelect(const SDLoc &DL, MVT VT, SDValue LHS, SDValue RHS,
4324
4324
return DAG.getNode(ISD::OR, DL, VT, LHS, RHS);
4325
4325
}
4326
4326
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
-
4356
4327
void llvm::createUnpackShuffleMask(EVT VT, SmallVectorImpl<int> &Mask,
4357
4328
bool Lo, bool Unary) {
4358
4329
assert(VT.getScalarType().isSimple() && (VT.getSizeInBits() % 128) == 0 &&
@@ -4910,6 +4881,35 @@ static bool getTargetShuffleMaskIndices(SDValue MaskNode,
4910
4881
return true;
4911
4882
}
4912
4883
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
+
4913
4913
/// Create a shuffle mask that matches the PACKSS/PACKUS truncation.
4914
4914
/// A multi-stage pack shuffle mask is created by specifying NumStages > 1.
4915
4915
/// Note: This ignores saturation, so inputs must be checked first.
0 commit comments