aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2008-05-22 06:43:33 +0000
committerGabor Greif <ggreif@gmail.com>2008-05-22 06:43:33 +0000
commitde2d74b213844b17eb5327fba27f21e699d3af66 (patch)
tree1c7d3b2ae87badcf533fa297fb1f2f6639bf0ec9 /lib/Analysis
parent687a4cb2955ce1b4eaf28134c4f8c57e0cacfa68 (diff)
downloadexternal_llvm-de2d74b213844b17eb5327fba27f21e699d3af66.zip
external_llvm-de2d74b213844b17eb5327fba27f21e699d3af66.tar.gz
external_llvm-de2d74b213844b17eb5327fba27f21e699d3af66.tar.bz2
Rewrite operand loops to use iterators. This shrinks .o file (at gcc4.0.1 -O3 x86) substantially (>500 bytes). Reason still unknown.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51423 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/ConstantFolding.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 7601aeb..e260d24 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -65,8 +65,9 @@ static bool IsConstantOffsetFromGlobal(Constant *C, GlobalValue *&GV,
// Otherwise, add any offset that our operands provide.
gep_type_iterator GTI = gep_type_begin(CE);
- for (unsigned i = 1, e = CE->getNumOperands(); i != e; ++i, ++GTI) {
- ConstantInt *CI = dyn_cast<ConstantInt>(CE->getOperand(i));
+ for (User::const_op_iterator i = CE->op_begin() + 1, e = CE->op_end();
+ i != e; ++i, ++GTI) {
+ ConstantInt *CI = dyn_cast<ConstantInt>(*i);
if (!CI) return false; // Index isn't a simple constant?
if (CI->getZExtValue() == 0) continue; // Not adding anything.
@@ -297,8 +298,8 @@ Constant *llvm::ConstantFoldInstruction(Instruction *I, const TargetData *TD) {
// Scan the operand list, checking to see if they are all constants, if so,
// hand off to ConstantFoldInstOperands.
SmallVector<Constant*, 8> Ops;
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (Constant *Op = dyn_cast<Constant>(I->getOperand(i)))
+ for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
+ if (Constant *Op = dyn_cast<Constant>(*i))
Ops.push_back(Op);
else
return 0; // All operands not constant!