aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp9
-rw-r--r--lib/Target/PowerPC/PPCISelDAGToDAG.cpp11
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 766f846968..78f5623aed 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -562,6 +562,15 @@ void SelectionDAGLowering::visitBr(BranchInst &I) {
} else {
std::vector<SDOperand> Ops;
Ops.push_back(getRoot());
+ // If the false case is the current basic block, then this is a self
+ // loop. We do not want to emit "Loop: ... brcond Out; br Loop", as it
+ // adds an extra instruction in the loop. Instead, invert the
+ // condition and emit "Loop: ... br!cond Loop; br Out.
+ if (CurMBB == Succ1MBB) {
+ std::swap(Succ0MBB, Succ1MBB);
+ SDOperand True = DAG.getConstant(1, Cond.getValueType());
+ Cond = DAG.getNode(ISD::XOR, Cond.getValueType(), Cond, True);
+ }
Ops.push_back(Cond);
Ops.push_back(DAG.getBasicBlock(Succ0MBB));
Ops.push_back(DAG.getBasicBlock(Succ1MBB));
diff --git a/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index 08fdcb4660..b781ca5cd8 100644
--- a/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1046,17 +1046,6 @@ void PPCDAGToDAGISel::Select(SDOperand &Result, SDOperand Op) {
if (N->getOpcode() == ISD::BRTWOWAY_CC) {
SDOperand CondTrueBlock = N->getOperand(4);
SDOperand CondFalseBlock = N->getOperand(5);
-
- // If the false case is the current basic block, then this is a self loop.
- // We do not want to emit "Loop: ... brcond Out; br Loop", as it adds an
- // extra dispatch group to the loop. Instead, invert the condition and
- // emit "Loop: ... br!cond Loop; br Out
- if (cast<BasicBlockSDNode>(CondFalseBlock)->getBasicBlock() == BB) {
- std::swap(CondTrueBlock, CondFalseBlock);
- CC = getSetCCInverse(CC,
- MVT::isInteger(N->getOperand(2).getValueType()));
- }
-
unsigned Opc = getBCCForSetCC(CC);
SDOperand CB =
SDOperand(CurDAG->getTargetNode(PPC::COND_BRANCH, MVT::Other,