diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-13 03:43:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-13 03:43:57 +0000 |
commit | 62cc76e9cce68b4ea7b6c3f2b00522d3fa133788 (patch) | |
tree | 472baafed6de921939293eae37debbd52d9633bf /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 11dafaa3ecf090336cd0e68bea654dbccbb614ee (diff) | |
download | bcm5719-llvm-62cc76e9cce68b4ea7b6c3f2b00522d3fa133788.tar.gz bcm5719-llvm-62cc76e9cce68b4ea7b6c3f2b00522d3fa133788.zip |
Fix my previous patch to handle a degenerate case that the llvm-gcc
bootstrap buildbot tripped over.
llvm-svn: 121674
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 7f9ef7cfd20..68f6905d4b5 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1820,6 +1820,22 @@ static bool TryToSimplifyUncondBranchWithICmpInIt(ICmpInst *ICI) { return SimplifyCFG(BB) | true; } + // Ok, the block is reachable from the default dest. If the constant we're + // comparing exists in one of the other edges, then we can constant fold ICI + // and zap it. + if (SI->findCaseValue(Cst) != 0) { + Value *V; + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) + V = ConstantInt::getFalse(BB->getContext()); + else + V = ConstantInt::getTrue(BB->getContext()); + + ICI->replaceAllUsesWith(V); + ICI->eraseFromParent(); + // BB is now empty, so it is likely to simplify away. + return SimplifyCFG(BB) | true; + } + // The use of the icmp has to be in the 'end' block, by the only PHI node in // the block. BasicBlock *SuccBlock = BB->getTerminator()->getSuccessor(0); |