[llvm-commits] [llvm] r50203 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Chris Lattner
sabre at nondot.org
Wed Apr 23 17:21:50 PDT 2008
Author: lattner
Date: Wed Apr 23 19:21:50 2008
New Revision: 50203
URL: http://llvm.org/viewvc/llvm-project?rev=50203&view=rev
Log:
code restructuring, not functionality change.
Modified:
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=50203&r1=50202&r2=50203&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Apr 23 19:21:50 2008
@@ -1693,28 +1693,30 @@
} else {
for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) {
Instruction *Inst = BI++;
- if (Inst->getType() != Type::VoidTy &&
- !isa<StructType>(Inst->getType())) {
- LatticeVal &IV = Values[Inst];
- if (IV.isConstant() ||
- (IV.isUndefined() && !isa<TerminatorInst>(Inst))) {
- Constant *Const = IV.isConstant()
- ? IV.getConstant() : UndefValue::get(Inst->getType());
- DOUT << " Constant: " << *Const << " = " << *Inst;
-
- // Replaces all of the uses of a variable with uses of the
- // constant.
- Inst->replaceAllUsesWith(Const);
-
- // Delete the instruction.
- if (!isa<TerminatorInst>(Inst) && !isa<CallInst>(Inst))
- BB->getInstList().erase(Inst);
-
- // Hey, we just changed something!
- MadeChanges = true;
- ++IPNumInstRemoved;
- }
- }
+ if (Inst->getType() == Type::VoidTy ||
+ isa<StructType>(Inst->getType()) ||
+ isa<TerminatorInst>(Inst))
+ continue;
+
+ LatticeVal &IV = Values[Inst];
+ if (!IV.isConstant() && !IV.isUndefined())
+ continue;
+
+ Constant *Const = IV.isConstant()
+ ? IV.getConstant() : UndefValue::get(Inst->getType());
+ DOUT << " Constant: " << *Const << " = " << *Inst;
+
+ // Replaces all of the uses of a variable with uses of the
+ // constant.
+ Inst->replaceAllUsesWith(Const);
+
+ // Delete the instruction.
+ if (!isa<CallInst>(Inst))
+ Inst->eraseFromParent();
+
+ // Hey, we just changed something!
+ MadeChanges = true;
+ ++IPNumInstRemoved;
}
}
More information about the llvm-commits
mailing list