Skip to content

Commit 58d4470

Browse files
committed
[X86] Remove scaleVectorShuffleBlendMask and use APIntOps::ScaleBitMask directly.
1 parent 7b039c0 commit 58d4470

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10589,15 +10589,6 @@ static bool matchShuffleAsBlend(MVT VT, SDValue V1, SDValue V2,
1058910589
return true;
1059010590
}
1059110591

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-
1060110592
/// Try to emit a blend instruction for a shuffle.
1060210593
///
1060310594
/// 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,
4053940530
MVT SrcVT = N0.getOperand(0).getSimpleValueType();
4054040531
if ((VT.getScalarSizeInBits() % SrcVT.getScalarSizeInBits()) == 0 &&
4054140532
SrcVT.getScalarSizeInBits() >= 32) {
40542-
unsigned BlendMask = N.getConstantOperandVal(2);
4054340533
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);
4054640537
return DAG.getBitcast(
4054740538
VT, DAG.getNode(X86ISD::BLENDI, DL, SrcVT, N0.getOperand(0),
4054840539
N1.getOperand(0),
40549-
DAG.getTargetConstant(BlendMask, DL, MVT::i8)));
40540+
DAG.getTargetConstant(NewBlendMask.getZExtValue(),
40541+
DL, MVT::i8)));
4055040542
}
4055140543
}
4055240544
return SDValue();

0 commit comments

Comments
 (0)