diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-20 19:15:26 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-20 19:15:26 +0000 |
commit | 41dd31f0b095c4ace9e3ab36062e2e11b8445d41 (patch) | |
tree | 8b689954d990b40ab2c42dd81433e368e3dadf46 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 77729b82e7f8b44c76101d2b7e5367610b63561a (diff) | |
download | bcm5719-llvm-41dd31f0b095c4ace9e3ab36062e2e11b8445d41.tar.gz bcm5719-llvm-41dd31f0b095c4ace9e3ab36062e2e11b8445d41.zip |
[ValueTracking] Make isImpliedCondition return an Optional<bool>. NFC.
Phabricator Revision: http://reviews.llvm.org/D19277
llvm-svn: 266904
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 4976893ad51..43103bf6f44 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2722,19 +2722,20 @@ static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI, // If BI is reached from the true path of PBI and PBI's condition implies // BI's condition, we know the direction of the BI branch. - bool ImpliedTrue; if (PBI->getSuccessor(0) == BI->getParent() && - isImpliedCondition(PBI->getCondition(), BI->getCondition(), ImpliedTrue, - DL) && PBI->getSuccessor(0) != PBI->getSuccessor(1) && BB->getSinglePredecessor()) { - // Turn this into a branch on constant. - auto *OldCond = BI->getCondition(); - ConstantInt *CI = ImpliedTrue ? ConstantInt::getTrue(BB->getContext()) - : ConstantInt::getFalse(BB->getContext()); - BI->setCondition(CI); - RecursivelyDeleteTriviallyDeadInstructions(OldCond); - return true; // Nuke the branch on constant. + Optional<bool> Implication = + isImpliedCondition(PBI->getCondition(), BI->getCondition(), DL); + if (Implication) { + // Turn this into a branch on constant. + auto *OldCond = BI->getCondition(); + ConstantInt *CI = *Implication ? ConstantInt::getTrue(BB->getContext()) + : ConstantInt::getFalse(BB->getContext()); + BI->setCondition(CI); + RecursivelyDeleteTriviallyDeadInstructions(OldCond); + return true; // Nuke the branch on constant. + } } // If both branches are conditional and both contain stores to the same |