From 1f083543c91341c0f663a53342bc42742e194abd Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 17 Jun 2016 12:20:50 +0000 Subject: [PATCH] [X86] Pre-size several SmallVectors instead of calling push_back in a loop. NFC llvm-svn: 272997 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 3ab273c9c243..623ba20ecefd 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -4684,10 +4684,10 @@ static SDValue getOnesVector(EVT VT, const X86Subtarget &Subtarget, static SDValue getUnpackl(SelectionDAG &DAG, const SDLoc &dl, MVT VT, SDValue V1, SDValue V2) { unsigned NumElems = VT.getVectorNumElements(); - SmallVector Mask; + SmallVector Mask(NumElems); for (unsigned i = 0, e = NumElems/2; i != e; ++i) { - Mask.push_back(i); - Mask.push_back(i + NumElems); + Mask[i * 2] = i; + Mask[i * 2 + 1] = i + NumElems; } return DAG.getVectorShuffle(VT, dl, V1, V2, &Mask[0]); } @@ -4696,10 +4696,10 @@ static SDValue getUnpackl(SelectionDAG &DAG, const SDLoc &dl, MVT VT, static SDValue getUnpackh(SelectionDAG &DAG, const SDLoc &dl, MVT VT, SDValue V1, SDValue V2) { unsigned NumElems = VT.getVectorNumElements(); - SmallVector Mask; + SmallVector Mask(NumElems); for (unsigned i = 0, Half = NumElems/2; i != Half; ++i) { - Mask.push_back(i + Half); - Mask.push_back(i + NumElems + Half); + Mask[i * 2] = i + Half; + Mask[i * 2 + 1] = i + NumElems + Half; } return DAG.getVectorShuffle(VT, dl, V1, V2, &Mask[0]); } @@ -4708,18 +4708,18 @@ static SDValue getUnpackh(SelectionDAG &DAG, const SDLoc &dl, MVT VT, /// This produces a shuffle where the low element of V2 is swizzled into the /// zero/undef vector, landing at element Idx. /// This produces a shuffle mask like 4,1,2,3 (idx=0) or 0,1,2,4 (idx=3). -static SDValue getShuffleVectorZeroOrUndef(SDValue V2, unsigned Idx, +static SDValue getShuffleVectorZeroOrUndef(SDValue V2, int Idx, bool IsZero, const X86Subtarget &Subtarget, SelectionDAG &DAG) { MVT VT = V2.getSimpleValueType(); SDValue V1 = IsZero ? getZeroVector(VT, Subtarget, DAG, SDLoc(V2)) : DAG.getUNDEF(VT); - unsigned NumElems = VT.getVectorNumElements(); - SmallVector MaskVec; - for (unsigned i = 0; i != NumElems; ++i) + int NumElems = VT.getVectorNumElements(); + SmallVector MaskVec(NumElems); + for (int i = 0; i != NumElems; ++i) // If this is the insertion idx, put the low elt of V2 here. - MaskVec.push_back(i == Idx ? NumElems : i); + MaskVec[i] = (i == Idx) ? NumElems : i; return DAG.getVectorShuffle(VT, SDLoc(V2), V1, V2, &MaskVec[0]); } @@ -10955,7 +10955,7 @@ static SDValue lowerShuffleAsRepeatedMaskAndLanePermute( } // Bail if we already have a repeated lane shuffle mask. - SmallVector RepeatedShuffleMask((unsigned)NumLaneElts, -1); + SmallVector RepeatedShuffleMask; if (is128BitLaneRepeatedShuffleMask(VT, Mask, RepeatedShuffleMask)) return SDValue();