diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-01-31 04:40:53 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-01-31 04:40:53 +0000 |
| commit | f96f4a874cd2e24e297a8888135889b89126e0f4 (patch) | |
| tree | d5dc57542a00970ef467105db591dd6a7925381b /llvm/lib/Transforms/Scalar | |
| parent | 302116a5ec74c8912e552b3dbc03045a585e6302 (diff) | |
| download | bcm5719-llvm-f96f4a874cd2e24e297a8888135889b89126e0f4.tar.gz bcm5719-llvm-f96f4a874cd2e24e297a8888135889b89126e0f4.zip | |
eliminate temporary vectors
llvm-svn: 33693
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
2 files changed, 13 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index adbc29613d0..c11d249f1f5 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -173,9 +173,10 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN, /*empty*/; if (isa<SequentialType>(*GTI)) { // Pull the last index out of the constant expr GEP. - std::vector<Value*> CEIdxs(CE->op_begin()+1, CE->op_end()-1); + SmallVector<Value*, 8> CEIdxs(CE->op_begin()+1, CE->op_end()-1); Constant *NCE = ConstantExpr::getGetElementPtr(CE->getOperand(0), - CEIdxs); + &CEIdxs[0], + CEIdxs.size()); GetElementPtrInst *NGEPI = new GetElementPtrInst(NCE, Constant::getNullValue(Type::Int32Ty), NewAdd, GEPI->getName(), GEPI); diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 3ce0f6f403b..39841d6cee7 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/PatternMatch.h" #include "llvm/Support/Compiler.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include <algorithm> @@ -7797,13 +7798,14 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { // constants, we can promote this to a constexpr instead of an instruction. // Scan for nonconstants... - std::vector<Constant*> Indices; + SmallVector<Constant*, 8> Indices; User::op_iterator I = GEP.idx_begin(), E = GEP.idx_end(); for (; I != E && isa<Constant>(*I); ++I) Indices.push_back(cast<Constant>(*I)); if (I == E) { // If they are all constants... - Constant *CE = ConstantExpr::getGetElementPtr(GV, Indices); + Constant *CE = ConstantExpr::getGetElementPtr(GV, + &Indices[0],Indices.size()); // Replace all uses of the GEP with the new constexpr... return ReplaceInstUsesWith(GEP, CE); @@ -8001,8 +8003,9 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) { if (const ArrayType *ASrcTy = dyn_cast<ArrayType>(SrcPTy)) if (Constant *CSrc = dyn_cast<Constant>(CastOp)) if (ASrcTy->getNumElements() != 0) { - std::vector<Value*> Idxs(2, Constant::getNullValue(Type::Int32Ty)); - CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs); + Value *Idxs[2]; + Idxs[0] = Idxs[1] = Constant::getNullValue(Type::Int32Ty); + CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs, 2); SrcTy = cast<PointerType>(CastOp->getType()); SrcPTy = SrcTy->getElementType(); } @@ -8188,8 +8191,9 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { if (const ArrayType *ASrcTy = dyn_cast<ArrayType>(SrcPTy)) if (Constant *CSrc = dyn_cast<Constant>(CastOp)) if (ASrcTy->getNumElements() != 0) { - std::vector<Value*> Idxs(2, Constant::getNullValue(Type::Int32Ty)); - CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs); + Value* Idxs[2]; + Idxs[0] = Idxs[1] = Constant::getNullValue(Type::Int32Ty); + CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs, 2); SrcTy = cast<PointerType>(CastOp->getType()); SrcPTy = SrcTy->getElementType(); } |

