[llvm] r272997 - [X86] Pre-size several SmallVectors instead of calling push_back in a loop. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 05:20:50 PDT 2016
Author: ctopper
Date: Fri Jun 17 07:20:50 2016
New Revision: 272997
URL: http://llvm.org/viewvc/llvm-project?rev=272997&view=rev
Log:
[X86] Pre-size several SmallVectors instead of calling push_back in a loop. NFC
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=272997&r1=272996&r2=272997&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jun 17 07:20:50 2016
@@ -4684,10 +4684,10 @@ static SDValue getOnesVector(EVT VT, con
static SDValue getUnpackl(SelectionDAG &DAG, const SDLoc &dl, MVT VT,
SDValue V1, SDValue V2) {
unsigned NumElems = VT.getVectorNumElements();
- SmallVector<int, 8> Mask;
+ SmallVector<int, 8> 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 &
static SDValue getUnpackh(SelectionDAG &DAG, const SDLoc &dl, MVT VT,
SDValue V1, SDValue V2) {
unsigned NumElems = VT.getVectorNumElements();
- SmallVector<int, 8> Mask;
+ SmallVector<int, 8> 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 &
/// 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<int, 16> MaskVec;
- for (unsigned i = 0; i != NumElems; ++i)
+ int NumElems = VT.getVectorNumElements();
+ SmallVector<int, 16> 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 lowerShuffleAsRepeatedMas
}
// Bail if we already have a repeated lane shuffle mask.
- SmallVector<int, 8> RepeatedShuffleMask((unsigned)NumLaneElts, -1);
+ SmallVector<int, 8> RepeatedShuffleMask;
if (is128BitLaneRepeatedShuffleMask(VT, Mask, RepeatedShuffleMask))
return SDValue();
More information about the llvm-commits
mailing list