@@ -10589,15 +10589,6 @@ static bool matchShuffleAsBlend(MVT VT, SDValue V1, SDValue V2,
10589
10589
return true;
10590
10590
}
10591
10591
10592
- static uint64_t scaleVectorShuffleBlendMask(uint64_t BlendMask, int Size,
10593
- int Scale) {
10594
- uint64_t ScaledMask = 0;
10595
- for (int i = 0; i != Size; ++i)
10596
- if (BlendMask & (1ull << i))
10597
- ScaledMask |= ((1ull << Scale) - 1) << (i * Scale);
10598
- return ScaledMask;
10599
- }
10600
-
10601
10592
/// Try to emit a blend instruction for a shuffle.
10602
10593
///
10603
10594
/// This doesn't do any checks for the availability of instructions for blending
@@ -40539,14 +40530,15 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
40539
40530
MVT SrcVT = N0.getOperand(0).getSimpleValueType();
40540
40531
if ((VT.getScalarSizeInBits() % SrcVT.getScalarSizeInBits()) == 0 &&
40541
40532
SrcVT.getScalarSizeInBits() >= 32) {
40542
- unsigned BlendMask = N.getConstantOperandVal(2);
40543
40533
unsigned Size = VT.getVectorNumElements();
40544
- unsigned Scale = VT.getScalarSizeInBits() / SrcVT.getScalarSizeInBits();
40545
- BlendMask = scaleVectorShuffleBlendMask(BlendMask, Size, Scale);
40534
+ unsigned NewSize = SrcVT.getVectorNumElements();
40535
+ APInt BlendMask = N.getConstantOperandAPInt(2).zextOrTrunc(Size);
40536
+ APInt NewBlendMask = APIntOps::ScaleBitMask(BlendMask, NewSize);
40546
40537
return DAG.getBitcast(
40547
40538
VT, DAG.getNode(X86ISD::BLENDI, DL, SrcVT, N0.getOperand(0),
40548
40539
N1.getOperand(0),
40549
- DAG.getTargetConstant(BlendMask, DL, MVT::i8)));
40540
+ DAG.getTargetConstant(NewBlendMask.getZExtValue(),
40541
+ DL, MVT::i8)));
40550
40542
}
40551
40543
}
40552
40544
return SDValue();
0 commit comments