[llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp InstructionCombining.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 30 20:41:11 PST 2007
Changes in directory llvm/lib/Transforms/Scalar:
IndVarSimplify.cpp updated: 1.106 -> 1.107
InstructionCombining.cpp updated: 1.615 -> 1.616
---
Log message:
eliminate temporary vectors
---
Diffs of the changes: (+13 -8)
IndVarSimplify.cpp | 5 +++--
InstructionCombining.cpp | 16 ++++++++++------
2 files changed, 13 insertions(+), 8 deletions(-)
Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.106 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.107
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.106 Sun Jan 14 20:27:26 2007
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Tue Jan 30 22:40:53 2007
@@ -173,9 +173,10 @@
/*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);
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.615 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.616
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.615 Tue Jan 30 18:53:10 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jan 30 22:40:53 2007
@@ -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 @@
// 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 @@
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 @@
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();
}
More information about the llvm-commits
mailing list