diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-24 00:16:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-24 00:16:28 +0000 |
commit | b6f89367553da76523ce4aff07b793e7e504d0f5 (patch) | |
tree | e24b4dab0828d98ecfaa67e47a4817edceca7a35 /lib/Transforms | |
parent | dc2dc029a9c8066f3e8db8f8c62bdbd48b6f357f (diff) | |
download | external_llvm-b6f89367553da76523ce4aff07b793e7e504d0f5.zip external_llvm-b6f89367553da76523ce4aff07b793e7e504d0f5.tar.gz external_llvm-b6f89367553da76523ce4aff07b793e7e504d0f5.tar.bz2 |
code cleanup, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index da92cc4..bef13af 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/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; } } |