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 | 5ef9ebf787252d294d6b120ccc4053703ebc3e84 (patch) | |
tree | 821064540499211eb7be60248d6bb06a18df4dc0 /llvm/lib/Transforms/Scalar/TailDuplication.cpp | |
parent | c92fa42ddd5c96ff1853b8a445548cf11d3f0f32 (diff) | |
download | bcm5719-llvm-5ef9ebf787252d294d6b120ccc4053703ebc3e84.tar.gz bcm5719-llvm-5ef9ebf787252d294d6b120ccc4053703ebc3e84.zip |
simplify code.
llvm-svn: 60190
Diffstat (limited to 'llvm/lib/Transforms/Scalar/TailDuplication.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailDuplication.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailDuplication.cpp b/llvm/lib/Transforms/Scalar/TailDuplication.cpp index 568ec06e39f..78690699bd5 100644 --- a/llvm/lib/Transforms/Scalar/TailDuplication.cpp +++ b/llvm/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! } |