- // Erase the psuedo COND_BRANCH instruction, and then back up the
- // iterator so that when the for loop increments it, we end up in
- // the correct place rather than iterating off the end.
- MBB->erase(MBBI);
- MBBI = --MBBJ;
+ unsigned Opcode;
+ switch (Pred) {
+ default: assert(0 && "Unknown cond branch predicate!");
+ case PPC::PRED_LT: Opcode = PPC::BLT; break;
+ case PPC::PRED_LE: Opcode = PPC::BLE; break;
+ case PPC::PRED_EQ: Opcode = PPC::BEQ; break;
+ case PPC::PRED_GE: Opcode = PPC::BGE; break;
+ case PPC::PRED_GT: Opcode = PPC::BGT; break;
+ case PPC::PRED_NE: Opcode = PPC::BNE; break;
+ case PPC::PRED_UN: Opcode = PPC::BUN; break;
+ case PPC::PRED_NU: Opcode = PPC::BNU; break;
+ }
+
+ MachineBasicBlock::iterator MBBJ;
+ if (ShortBranchOk) {
+ MBBJ = BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addMBB(DestMBB);
+ } else {
+ // Long branch, skip next branch instruction (i.e. $PC+8).
+ ++NumExpanded;
+ BuildMI(*MBB, MBBI, Opcode, 2).addReg(CRReg).addImm(2);
+ MBBJ = BuildMI(*MBB, MBBI, PPC::B, 1).addMBB(DestMBB);