@@ -7401,8 +7401,8 @@ static bool getFauxShuffleMask(SDValue N, const APInt &DemandedElts,
7401
7401
7402
7402
// Handle OR(SHUFFLE,SHUFFLE) case where one source is zero and the other
7403
7403
// is a valid shuffle index.
7404
- SDValue N0 = peekThroughBitcasts (N.getOperand(0));
7405
- SDValue N1 = peekThroughBitcasts (N.getOperand(1));
7404
+ SDValue N0 = peekThroughOneUseBitcasts (N.getOperand(0));
7405
+ SDValue N1 = peekThroughOneUseBitcasts (N.getOperand(1));
7406
7406
if (!N0.getValueType().isVector() || !N1.getValueType().isVector())
7407
7407
return false;
7408
7408
SmallVector<int, 64> SrcMask0, SrcMask1;
@@ -7413,24 +7413,34 @@ static bool getFauxShuffleMask(SDValue N, const APInt &DemandedElts,
7413
7413
true))
7414
7414
return false;
7415
7415
7416
+ // Shuffle inputs must be the same size as the result.
7417
+ if (llvm::any_of(SrcInputs0, [VT](SDValue Op) {
7418
+ return VT.getSizeInBits() != Op.getValueSizeInBits();
7419
+ }))
7420
+ return false;
7421
+ if (llvm::any_of(SrcInputs1, [VT](SDValue Op) {
7422
+ return VT.getSizeInBits() != Op.getValueSizeInBits();
7423
+ }))
7424
+ return false;
7425
+
7416
7426
size_t MaskSize = std::max(SrcMask0.size(), SrcMask1.size());
7417
7427
SmallVector<int, 64> Mask0, Mask1;
7418
7428
narrowShuffleMaskElts(MaskSize / SrcMask0.size(), SrcMask0, Mask0);
7419
7429
narrowShuffleMaskElts(MaskSize / SrcMask1.size(), SrcMask1, Mask1);
7420
- for (int i = 0; i != (int) MaskSize; ++i) {
7430
+ for (size_t i = 0; i != MaskSize; ++i) {
7421
7431
if (Mask0[i] == SM_SentinelUndef && Mask1[i] == SM_SentinelUndef)
7422
7432
Mask.push_back(SM_SentinelUndef);
7423
7433
else if (Mask0[i] == SM_SentinelZero && Mask1[i] == SM_SentinelZero)
7424
7434
Mask.push_back(SM_SentinelZero);
7425
7435
else if (Mask1[i] == SM_SentinelZero)
7426
- Mask.push_back(i );
7436
+ Mask.push_back(Mask0[i] );
7427
7437
else if (Mask0[i] == SM_SentinelZero)
7428
- Mask.push_back(i + MaskSize);
7438
+ Mask.push_back(Mask1[i] + (int)( MaskSize * SrcInputs0.size()) );
7429
7439
else
7430
7440
return false;
7431
7441
}
7432
- Ops.push_back(N0 );
7433
- Ops.push_back(N1 );
7442
+ Ops.append(SrcInputs0.begin(), SrcInputs0.end() );
7443
+ Ops.append(SrcInputs1.begin(), SrcInputs1.end() );
7434
7444
return true;
7435
7445
}
7436
7446
case ISD::INSERT_SUBVECTOR: {
@@ -34218,7 +34228,6 @@ static bool matchBinaryShuffle(MVT MaskVT, ArrayRef<int> Mask,
34218
34228
SelectionDAG &DAG, const X86Subtarget &Subtarget,
34219
34229
unsigned &Shuffle, MVT &SrcVT, MVT &DstVT,
34220
34230
bool IsUnary) {
34221
- unsigned NumMaskElts = Mask.size();
34222
34231
unsigned EltSizeInBits = MaskVT.getScalarSizeInBits();
34223
34232
34224
34233
if (MaskVT.is128BitVector()) {
@@ -34276,46 +34285,6 @@ static bool matchBinaryShuffle(MVT MaskVT, ArrayRef<int> Mask,
34276
34285
}
34277
34286
}
34278
34287
34279
- // Attempt to match against a OR if we're performing a blend shuffle and the
34280
- // non-blended source element is zero in each case.
34281
- if ((EltSizeInBits % V1.getScalarValueSizeInBits()) == 0 &&
34282
- (EltSizeInBits % V2.getScalarValueSizeInBits()) == 0) {
34283
- bool IsBlend = true;
34284
- unsigned NumV1Elts = V1.getValueType().getVectorNumElements();
34285
- unsigned NumV2Elts = V2.getValueType().getVectorNumElements();
34286
- unsigned Scale1 = NumV1Elts / NumMaskElts;
34287
- unsigned Scale2 = NumV2Elts / NumMaskElts;
34288
- APInt DemandedZeroV1 = APInt::getNullValue(NumV1Elts);
34289
- APInt DemandedZeroV2 = APInt::getNullValue(NumV2Elts);
34290
- for (unsigned i = 0; i != NumMaskElts; ++i) {
34291
- int M = Mask[i];
34292
- if (M == SM_SentinelUndef)
34293
- continue;
34294
- if (M == SM_SentinelZero) {
34295
- DemandedZeroV1.setBits(i * Scale1, (i + 1) * Scale1);
34296
- DemandedZeroV2.setBits(i * Scale2, (i + 1) * Scale2);
34297
- continue;
34298
- }
34299
- if (M == i) {
34300
- DemandedZeroV2.setBits(i * Scale2, (i + 1) * Scale2);
34301
- continue;
34302
- }
34303
- if (M == (i + NumMaskElts)) {
34304
- DemandedZeroV1.setBits(i * Scale1, (i + 1) * Scale1);
34305
- continue;
34306
- }
34307
- IsBlend = false;
34308
- break;
34309
- }
34310
- if (IsBlend &&
34311
- DAG.computeKnownBits(V1, DemandedZeroV1).isZero() &&
34312
- DAG.computeKnownBits(V2, DemandedZeroV2).isZero()) {
34313
- Shuffle = ISD::OR;
34314
- SrcVT = DstVT = EVT(MaskVT).changeTypeToInteger().getSimpleVT();
34315
- return true;
34316
- }
34317
- }
34318
-
34319
34288
return false;
34320
34289
}
34321
34290
0 commit comments