summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SCCP.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-24 00:16:28 +0000
committerChris Lattner <sabre@nondot.org>2008-04-24 00:16:28 +0000
commit769203cb03e8212ec56f46e25bfd792d39a99cfa (patch)
treef80ef237a31796e2626acae1f3137d167c2dbe2a /llvm/lib/Transforms/Scalar/SCCP.cpp
parent86bbf338e57504cc1e006552d8a1a2d99302e961 (diff)
downloadbcm5719-llvm-769203cb03e8212ec56f46e25bfd792d39a99cfa.tar.gz
bcm5719-llvm-769203cb03e8212ec56f46e25bfd792d39a99cfa.zip
code cleanup, no functionality change.
llvm-svn: 50201
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index da92cc40488..bef13affd8b 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -1516,25 +1516,27 @@ bool SCCP::runOnFunction(Function &F) {
//
for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) {
Instruction *Inst = BI++;
- if (Inst->getType() != Type::VoidTy) {
- 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.
- BB->getInstList().erase(Inst);
-
- // Hey, we just changed something!
- MadeChanges = true;
- ++NumInstRemoved;
- }
- }
+ if (Inst->getType() == Type::VoidTy ||
+ 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.
+ Inst->eraseFromParent();
+
+ // Hey, we just changed something!
+ MadeChanges = true;
+ ++NumInstRemoved;
}
}
OpenPOWER on IntegriCloud