diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-09-29 05:43:32 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-09-29 05:43:32 +0000 |
| commit | 879ce7894c95f8cb3beb2e1577d182994ffd64c5 (patch) | |
| tree | c47e07f410cc27ef5ba1875ba27b7ee174c47232 /llvm/lib/Transforms/Utils | |
| parent | 6a4adcda4cfcfc893e0d78c7a9fa1f39ff532c47 (diff) | |
| download | bcm5719-llvm-879ce7894c95f8cb3beb2e1577d182994ffd64c5.tar.gz bcm5719-llvm-879ce7894c95f8cb3beb2e1577d182994ffd64c5.zip | |
Do not insert trivially dead select instructions, which allows us to
potentially fold more in one pass.
llvm-svn: 16583
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index baa737eddb8..77d3fe36583 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -753,10 +753,19 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { FalseSucc->removePredecessor(BI->getParent()); // Insert a new select instruction. - Value *NewRetVal = new SelectInst(BI->getCondition(), TrueValue, - FalseValue, "retval", BI); + Value *NewRetVal; + Value *BrCond = BI->getCondition(); + if (TrueValue != FalseValue) + NewRetVal = new SelectInst(BrCond, TrueValue, + FalseValue, "retval", BI); + else + NewRetVal = TrueValue; + new ReturnInst(NewRetVal, BI); BI->getParent()->getInstList().erase(BI); + if (BrCond->use_empty()) + if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond)) + BrCondI->getParent()->getInstList().erase(BrCondI); return true; } } |

