summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@codeaurora.org>2016-04-20 19:15:26 +0000
committerChad Rosier <mcrosier@codeaurora.org>2016-04-20 19:15:26 +0000
commit41dd31f0b095c4ace9e3ab36062e2e11b8445d41 (patch)
tree8b689954d990b40ab2c42dd81433e368e3dadf46 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent77729b82e7f8b44c76101d2b7e5367610b63561a (diff)
downloadbcm5719-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.cpp21
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
OpenPOWER on IntegriCloud