diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-19 17:19:14 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-19 17:19:14 +0000 |
commit | b7dfbb40a3fd9491c0188eca0ed2af66fa5ef44f (patch) | |
tree | 16244dfe2289ef44c3491a20a63af0f9516cfaa5 /llvm/lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 79e096dbaf974a775e72181d748c4e7c3e659047 (diff) | |
download | llvm-b7dfbb40a3fd9491c0188eca0ed2af66fa5ef44f.zip llvm-b7dfbb40a3fd9491c0188eca0ed2af66fa5ef44f.tar.gz llvm-b7dfbb40a3fd9491c0188eca0ed2af66fa5ef44f.tar.bz2 |
[ValueTracking] Improve isImpliedCondition for conditions with matching operands.
This patch improves SimplifyCFG to catch cases like:
if (a < b) {
if (a > b) <- known to be false
unreachable;
}
Phabricator Revision: http://reviews.llvm.org/D18905
llvm-svn: 266767
Diffstat (limited to 'llvm/lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/JumpThreading.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index 2def0b5..d68dd14 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -928,9 +928,10 @@ bool JumpThreading::ProcessImpliedCondition(BasicBlock *BB) { if (!PBI || !PBI->isConditional() || PBI->getSuccessor(0) != CurrentBB) return false; - if (isImpliedCondition(PBI->getCondition(), Cond, DL)) { - BI->getSuccessor(1)->removePredecessor(BB); - BranchInst::Create(BI->getSuccessor(0), BI); + bool ImpliedTrue; + if (isImpliedCondition(PBI->getCondition(), Cond, ImpliedTrue, DL)) { + BI->getSuccessor(ImpliedTrue ? 1 : 0)->removePredecessor(BB); + BranchInst::Create(BI->getSuccessor(ImpliedTrue ? 0 : 1), BI); BI->eraseFromParent(); return true; } |