Skip to content

Commit

Permalink
[X86] Remove scaleVectorShuffleBlendMask and use APIntOps::ScaleBitMa…
Browse files Browse the repository at this point in the history
…sk directly.
  • Loading branch information
RKSimon committed Apr 15, 2024
1 parent 7b039c0 commit 58d4470
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10589,15 +10589,6 @@ static bool matchShuffleAsBlend(MVT VT, SDValue V1, SDValue V2,
return true;
}

static uint64_t scaleVectorShuffleBlendMask(uint64_t BlendMask, int Size,
int Scale) {
uint64_t ScaledMask = 0;
for (int i = 0; i != Size; ++i)
if (BlendMask & (1ull << i))
ScaledMask |= ((1ull << Scale) - 1) << (i * Scale);
return ScaledMask;
}

/// Try to emit a blend instruction for a shuffle.
///
/// This doesn't do any checks for the availability of instructions for blending
Expand Down Expand Up @@ -40539,14 +40530,15 @@ static SDValue combineTargetShuffle(SDValue N, const SDLoc &DL,
MVT SrcVT = N0.getOperand(0).getSimpleValueType();
if ((VT.getScalarSizeInBits() % SrcVT.getScalarSizeInBits()) == 0 &&
SrcVT.getScalarSizeInBits() >= 32) {
unsigned BlendMask = N.getConstantOperandVal(2);
unsigned Size = VT.getVectorNumElements();
unsigned Scale = VT.getScalarSizeInBits() / SrcVT.getScalarSizeInBits();
BlendMask = scaleVectorShuffleBlendMask(BlendMask, Size, Scale);
unsigned NewSize = SrcVT.getVectorNumElements();
APInt BlendMask = N.getConstantOperandAPInt(2).zextOrTrunc(Size);
APInt NewBlendMask = APIntOps::ScaleBitMask(BlendMask, NewSize);
return DAG.getBitcast(
VT, DAG.getNode(X86ISD::BLENDI, DL, SrcVT, N0.getOperand(0),
N1.getOperand(0),
DAG.getTargetConstant(BlendMask, DL, MVT::i8)));
DAG.getTargetConstant(NewBlendMask.getZExtValue(),
DL, MVT::i8)));
}
}
return SDValue();
Expand Down

0 comments on commit 58d4470

Please sign in to comment.