[X86] Avoid making a copy of a shuffle mask until we're sure we really need to. And just use a SmallVector to do the copy because its easy.

llvm-svn: 273135
This commit is contained in:
Craig Topper 2016-06-20 04:00:50 +00:00
parent 440138c4c8
commit 01ef65dd79
1 changed files with 7 additions and 7 deletions

View File

@ -9841,17 +9841,14 @@ static SDValue lowerV8I16VectorShuffle(SDValue Op, SDValue V1, SDValue V2,
assert(V1.getSimpleValueType() == MVT::v8i16 && "Bad operand type!"); assert(V1.getSimpleValueType() == MVT::v8i16 && "Bad operand type!");
assert(V2.getSimpleValueType() == MVT::v8i16 && "Bad operand type!"); assert(V2.getSimpleValueType() == MVT::v8i16 && "Bad operand type!");
ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(Op); ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(Op);
ArrayRef<int> OrigMask = SVOp->getMask(); ArrayRef<int> Mask = SVOp->getMask();
int MaskStorage[8] = {OrigMask[0], OrigMask[1], OrigMask[2], OrigMask[3],
OrigMask[4], OrigMask[5], OrigMask[6], OrigMask[7]};
MutableArrayRef<int> Mask(MaskStorage);
assert(Mask.size() == 8 && "Unexpected mask size for v8 shuffle!"); assert(Mask.size() == 8 && "Unexpected mask size for v8 shuffle!");
// Whenever we can lower this as a zext, that instruction is strictly faster // Whenever we can lower this as a zext, that instruction is strictly faster
// than any alternative. // than any alternative.
if (SDValue ZExt = lowerVectorShuffleAsZeroOrAnyExtend( if (SDValue ZExt = lowerVectorShuffleAsZeroOrAnyExtend(
DL, MVT::v8i16, V1, V2, OrigMask, Subtarget, DAG)) DL, MVT::v8i16, V1, V2, Mask, Subtarget, DAG))
return ZExt; return ZExt;
int NumV2Inputs = count_if(Mask, [](int M) { return M >= 8; }); int NumV2Inputs = count_if(Mask, [](int M) { return M >= 8; });
@ -9877,8 +9874,11 @@ static SDValue lowerV8I16VectorShuffle(SDValue Op, SDValue V1, SDValue V2,
Mask, Subtarget, DAG)) Mask, Subtarget, DAG))
return Rotate; return Rotate;
return lowerV8I16GeneralSingleInputVectorShuffle(DL, MVT::v8i16, V1, Mask, // Make a copy of the mask so it can be modified.
Subtarget, DAG); SmallVector<int, 8> MutableMask(Mask.begin(), Mask.end());
return lowerV8I16GeneralSingleInputVectorShuffle(DL, MVT::v8i16, V1,
MutableMask, Subtarget,
DAG);
} }
assert(llvm::any_of(Mask, [](int M) { return M >= 0 && M < 8; }) && assert(llvm::any_of(Mask, [](int M) { return M >= 0 && M < 8; }) &&