summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorGeoff Berry <gberry@codeaurora.org>2017-02-09 18:28:17 +0000
committerGeoff Berry <gberry@codeaurora.org>2017-02-09 18:28:17 +0000
commit7e320c24855639e30a27c95e46ce288e3e5fff2a (patch)
treef1ee0fec5f2de2e0581453fdb98d5770952835ef /llvm/lib/CodeGen
parent147f62fc0b1796ad27a6fb9f8cbbd60aac0b757d (diff)
downloadbcm5719-llvm-7e320c24855639e30a27c95e46ce288e3e5fff2a.tar.gz
bcm5719-llvm-7e320c24855639e30a27c95e46ce288e3e5fff2a.zip
[SelectionDAG] Fix bugs in inverted condition splitting code.
Summary: Fix two bugs in SelectionDAGBuilder::FindMergedConditions reported by Mikael Holmen. Handle non-canonicalized xor not operation correctly (was assuming operand 0 was always the non-constant operand) and check that the negated condition is also in the same block as the original and/or instruction (as is done for and/or operands already) before proceeding with optimization. Reviewers: bogner, MatzeB, qcolombet Subscribers: mcrosier, uabelho, llvm-commits Differential Revision: https://reviews.llvm.org/D29680 llvm-svn: 294605
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 1cd4b48f3d6..5966069d31b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1638,10 +1638,12 @@ void SelectionDAGBuilder::FindMergedConditions(const Value *Cond,
// Skip over not part of the tree and remember to invert op and operands at
// next level.
if (BinaryOperator::isNot(Cond) && Cond->hasOneUse()) {
- Cond = cast<Instruction>(Cond)->getOperand(0);
- FindMergedConditions(Cond, TBB, FBB, CurBB, SwitchBB, Opc, TProb, FProb,
- !InvertCond);
- return;
+ const Value *CondOp = BinaryOperator::getNotArgument(Cond);
+ if (InBlock(CondOp, CurBB->getBasicBlock())) {
+ FindMergedConditions(CondOp, TBB, FBB, CurBB, SwitchBB, Opc, TProb, FProb,
+ !InvertCond);
+ return;
+ }
}
const Instruction *BOp = dyn_cast<Instruction>(Cond);
OpenPOWER on IntegriCloud