[llvm-commits] [llvm] r51423 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp
Gabor Greif
ggreif at gmail.com
Wed May 21 23:43:33 PDT 2008
Author: ggreif
Date: Thu May 22 01:43:33 2008
New Revision: 51423
URL: http://llvm.org/viewvc/llvm-project?rev=51423&view=rev
Log:
Rewrite operand loops to use iterators. This shrinks .o file (at gcc4.0.1 -O3 x86) substantially (>500 bytes). Reason still unknown.
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=51423&r1=51422&r2=51423&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu May 22 01:43:33 2008
@@ -65,8 +65,9 @@
// 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 @@
// 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!
More information about the llvm-commits
mailing list