Optimize code a bit by calling push_back only once in some loops. Reduces compiled code size a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154473 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2012-04-11 03:06:35 +00:00
parent 92c904539a
commit 23de31b13b

View File

@ -2804,11 +2804,11 @@ void SelectionDAGBuilder::visitExtractElement(const User &I) {
} }
// Utility for visitShuffleVector - Return true if every element in Mask, // Utility for visitShuffleVector - Return true if every element in Mask,
// begining // from position Pos and ending in Pos+Size, falls within the // begining from position Pos and ending in Pos+Size, falls within the
// specified sequential range [L, L+Pos). or is undef. // specified sequential range [L, L+Pos). or is undef.
static bool isSequentialInRange(const SmallVectorImpl<int> &Mask, static bool isSequentialInRange(const SmallVectorImpl<int> &Mask,
int Pos, int Size, int Low) { unsigned Pos, unsigned Size, int Low) {
for (int i = Pos, e = Pos+Size; i != e; ++i, ++Low) for (unsigned i = Pos, e = Pos+Size; i != e; ++i, ++Low)
if (Mask[i] >= 0 && Mask[i] != Low) if (Mask[i] >= 0 && Mask[i] != Low)
return false; return false;
return true; return true;
@ -2878,10 +2878,9 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
SmallVector<int, 8> MappedOps; SmallVector<int, 8> MappedOps;
for (unsigned i = 0; i != MaskNumElts; ++i) { for (unsigned i = 0; i != MaskNumElts; ++i) {
int Idx = Mask[i]; int Idx = Mask[i];
if (Idx < (int)SrcNumElts) if (Idx >= (int)SrcNumElts)
MappedOps.push_back(Idx); Idx -= SrcNumElts - MaskNumElts;
else MappedOps.push_back(Idx);
MappedOps.push_back(Idx + MaskNumElts - SrcNumElts);
} }
setValue(&I, DAG.getVectorShuffle(VT, getCurDebugLoc(), Src1, Src2, setValue(&I, DAG.getVectorShuffle(VT, getCurDebugLoc(), Src1, Src2,
@ -2952,12 +2951,13 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
SmallVector<int, 8> MappedOps; SmallVector<int, 8> MappedOps;
for (unsigned i = 0; i != MaskNumElts; ++i) { for (unsigned i = 0; i != MaskNumElts; ++i) {
int Idx = Mask[i]; int Idx = Mask[i];
if (Idx < 0) if (Idx >= 0) {
MappedOps.push_back(Idx); if (Idx < (int)SrcNumElts)
else if (Idx < (int)SrcNumElts) Idx -= StartIdx[0];
MappedOps.push_back(Idx - StartIdx[0]); else
else Idx -= SrcNumElts + StartIdx[1] - MaskNumElts;
MappedOps.push_back(Idx - SrcNumElts - StartIdx[1] + MaskNumElts); }
MappedOps.push_back(Idx);
} }
setValue(&I, DAG.getVectorShuffle(VT, getCurDebugLoc(), Src1, Src2, setValue(&I, DAG.getVectorShuffle(VT, getCurDebugLoc(), Src1, Src2,
@ -2973,22 +2973,20 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
EVT PtrVT = TLI.getPointerTy(); EVT PtrVT = TLI.getPointerTy();
SmallVector<SDValue,8> Ops; SmallVector<SDValue,8> Ops;
for (unsigned i = 0; i != MaskNumElts; ++i) { for (unsigned i = 0; i != MaskNumElts; ++i) {
if (Mask[i] < 0) { int Idx = Mask[i];
Ops.push_back(DAG.getUNDEF(EltVT)); SDValue Res;
if (Idx < 0) {
Res = DAG.getUNDEF(EltVT);
} else { } else {
int Idx = Mask[i]; SDValue &Src = Idx < (int)SrcNumElts ? Src1 : Src2;
SDValue Res; if (Idx >= (int)SrcNumElts) Idx -= SrcNumElts;
if (Idx < (int)SrcNumElts) Res = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, getCurDebugLoc(),
Res = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, getCurDebugLoc(), EltVT, Src, DAG.getConstant(Idx, PtrVT));
EltVT, Src1, DAG.getConstant(Idx, PtrVT));
else
Res = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, getCurDebugLoc(),
EltVT, Src2,
DAG.getConstant(Idx - SrcNumElts, PtrVT));
Ops.push_back(Res);
} }
Ops.push_back(Res);
} }
setValue(&I, DAG.getNode(ISD::BUILD_VECTOR, getCurDebugLoc(), setValue(&I, DAG.getNode(ISD::BUILD_VECTOR, getCurDebugLoc(),