diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index bb3dc081fd6..45f4d3930a7 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -749,9 +749,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { unsigned NumDstElts = DstTy->getNumElements(); // Extract a subvector of the first NumDstElts lanes and sign/zero extend. - SmallVector ShuffleMask; + SmallVector ShuffleMask(NumDstElts); for (unsigned i = 0; i != NumDstElts; ++i) - ShuffleMask.push_back(i); + ShuffleMask[i] = i; Value *SV = Builder.CreateShuffleVector( CI->getArgOperand(0), UndefValue::get(SrcTy), ShuffleMask); @@ -817,11 +817,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { VectorType *VecTy = cast(CI->getType()); unsigned NumElts = VecTy->getNumElements(); - SmallVector Idxs; - for (unsigned i = 0; i != NumElts; ++i) { - unsigned Idx = ((Imm >> (i%8)) & 1) ? i + NumElts : i; - Idxs.push_back(Idx); - } + SmallVector Idxs(NumElts); + for (unsigned i = 0; i != NumElts; ++i) + Idxs[i] = ((Imm >> (i%8)) & 1) ? i + NumElts : i; Rep = Builder.CreateShuffleVector(Op0, Op1, Idxs); } else if (Name.startswith("llvm.x86.avx.vinsertf128.") || @@ -837,10 +835,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { // Extend the second operand into a vector that is twice as big. Value *UndefV = UndefValue::get(Op1->getType()); - SmallVector Idxs; - for (unsigned i = 0; i != NumElts; ++i) { - Idxs.push_back(i); - } + SmallVector Idxs(NumElts); + for (unsigned i = 0; i != NumElts; ++i) + Idxs[i] = i; Rep = Builder.CreateShuffleVector(Op1, UndefV, Idxs); // Insert the second operand into the first operand. @@ -854,19 +851,14 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { // Imm = 1 // Imm = 0 - Idxs.clear(); // The low half of the result is either the low half of the 1st operand // or the low half of the 2nd operand (the inserted vector). - for (unsigned i = 0; i != NumElts / 2; ++i) { - unsigned Idx = Imm ? i : (i + NumElts); - Idxs.push_back(Idx); - } + for (unsigned i = 0; i != NumElts / 2; ++i) + Idxs[i] = Imm ? i : (i + NumElts); // The high half of the result is either the low half of the 2nd operand // (the inserted vector) or the high half of the 1st operand. - for (unsigned i = NumElts / 2; i != NumElts; ++i) { - unsigned Idx = Imm ? (i + NumElts / 2) : i; - Idxs.push_back(Idx); - } + for (unsigned i = NumElts / 2; i != NumElts; ++i) + Idxs[i] = Imm ? (i + NumElts / 2) : i; Rep = Builder.CreateShuffleVector(Op0, Rep, Idxs); } else if (Name.startswith("llvm.x86.avx.vextractf128.") || Name == "llvm.x86.avx2.vextracti128") {