summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-12-09 17:50:10 +0000
committerJuergen Ributzka <juergen@apple.com>2014-12-09 17:50:10 +0000
commit8bda738221074ad5ba84b5a1d2f182ef4d630961 (patch)
tree224dd377dada3c20fa21453bc88c5e7e28d2efdd /llvm/lib
parent9cceddd074ffd48dcc612d49f7b55fe6e32a3a41 (diff)
downloadbcm5719-llvm-8bda738221074ad5ba84b5a1d2f182ef4d630961.tar.gz
bcm5719-llvm-8bda738221074ad5ba84b5a1d2f182ef4d630961.zip
[CGP] Rewrite pattern match for splitBranchCondition to work with Values instead.
Rewrite the pattern match code to work also with Values instead with Instructions only. Also remove the no longer need matcher (m_Instruction). llvm-svn: 223797
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index e043bfbfa27..96e2d3d74de 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -3869,12 +3869,12 @@ bool CodeGenPrepare::splitBranchCondition(Function &F) {
continue;
unsigned Opc;
- Instruction *Cond1, *Cond2;
- if (match(LogicOp, m_And(m_OneUse(m_Instruction(Cond1)),
- m_OneUse(m_Instruction(Cond2)))))
+ Value *Cond1, *Cond2;
+ if (match(LogicOp, m_And(m_OneUse(m_Value(Cond1)),
+ m_OneUse(m_Value(Cond2)))))
Opc = Instruction::And;
- else if (match(LogicOp, m_Or(m_OneUse(m_Instruction(Cond1)),
- m_OneUse(m_Instruction(Cond2)))))
+ else if (match(LogicOp, m_Or(m_OneUse(m_Value(Cond1)),
+ m_OneUse(m_Value(Cond2)))))
Opc = Instruction::Or;
else
continue;
@@ -3897,7 +3897,7 @@ bool CodeGenPrepare::splitBranchCondition(Function &F) {
auto *Br1 = cast<BranchInst>(BB.getTerminator());
Br1->setCondition(Cond1);
LogicOp->eraseFromParent();
- Cond2->removeFromParent();
+
// Depending on the conditon we have to either replace the true or the false
// successor of the original branch instruction.
if (Opc == Instruction::And)
@@ -3907,7 +3907,10 @@ bool CodeGenPrepare::splitBranchCondition(Function &F) {
// Fill in the new basic block.
auto *Br2 = IRBuilder<>(TmpBB).CreateCondBr(Cond2, TBB, FBB);
- Cond2->insertBefore(Br2);
+ if (auto *I = dyn_cast<Instruction>(Cond2)) {
+ I->removeFromParent();
+ I->insertBefore(Br2);
+ }
// Update PHI nodes in both successors. The original BB needs to be
// replaced in one succesor's PHI nodes, because the branch comes now from
OpenPOWER on IntegriCloud