diff options
author | Chris Lattner <sabre@nondot.org> | 2008-11-27 22:56:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-11-27 22:56:14 +0000 |
commit | 15678533f3c8baa6664fe9b513b614b8665f29fd (patch) | |
tree | 259bfca95398dba832422bd1358e70d51011c89d /lib/Transforms/Scalar/TailDuplication.cpp | |
parent | cb03f8547d9e0f4cf70d5eec226f2ccfbc8fdfe4 (diff) | |
download | external_llvm-15678533f3c8baa6664fe9b513b614b8665f29fd.zip external_llvm-15678533f3c8baa6664fe9b513b614b8665f29fd.tar.gz external_llvm-15678533f3c8baa6664fe9b513b614b8665f29fd.tar.bz2 |
simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/TailDuplication.cpp')
-rw-r--r-- | lib/Transforms/Scalar/TailDuplication.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 568ec06..7869069 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -27,6 +27,7 @@ #include "llvm/Pass.h" #include "llvm/Type.h" #include "llvm/Support/CFG.h" +#include "llvm/Analysis/ConstantFolding.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" @@ -348,10 +349,17 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) { // instructions one last time, constant propagating and DCE'ing them, because // they may not be needed anymore. // - if (HadPHINodes) - while (BI != SourceBlock->end()) - if (!dceInstruction(BI) && !doConstantPropagation(BI)) - ++BI; + if (HadPHINodes) { + while (BI != SourceBlock->end()) { + Instruction *Inst = BI++; + if (isInstructionTriviallyDead(Inst)) + Inst->eraseFromParent(); + else if (Constant *C = ConstantFoldInstruction(Inst)) { + Inst->replaceAllUsesWith(C); + Inst->eraseFromParent(); + } + } + } ++NumEliminated; // We just killed a branch! } |