Implement support for branch reversal, fix a bug in branch analysis.
authorChris Lattner <sabre@nondot.org>
Sat, 21 Oct 2006 06:03:11 +0000 (06:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 21 Oct 2006 06:03:11 +0000 (06:03 +0000)
This provides stuff like:

        cmpw cr0, r15, r29
        mr r14, r15
-       bge cr0, LBB3_111       ;bb656
-       b LBB3_90       ;bb501
+       blt cr0, LBB3_90        ;bb501
 LBB3_111:      ;bb656
        lwz r18, 68(r1)

which is particularly good for dispatch group formation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31101 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCInstrInfo.cpp

index 76cb7ed56946fe8c9d4925c3b8b3696bf9ed419e..63188466bed4b72b43eab7b91d36b25506f65c72 100644 (file)
@@ -186,7 +186,7 @@ bool PPCInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
       TBB = LastInst->getOperand(2).getMachineBasicBlock();
       Cond.push_back(LastInst->getOperand(0));
       Cond.push_back(LastInst->getOperand(1));
-      return true;
+      return false;
     }
     // Otherwise, don't know what this is.
     return true;
@@ -261,5 +261,8 @@ void PPCInstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
 
 bool PPCInstrInfo::
 ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
-  return true;
+  assert(Cond.size() == 2 && "Invalid PPC branch opcode!");
+  // Leave the CR# the same, but invert the condition.
+  Cond[1].setImm(invertPPCBranchOpcode(Cond[1].getImm()));
+  return false;
 }