Be more layout aware here and swap the successor and branch condition

if it means we get a fallthrough.

llvm-svn: 130404
This commit is contained in:
Eric Christopher 2011-04-28 16:52:09 +00:00
parent f81f789b6c
commit 4f012fd0a1
1 changed files with 8 additions and 1 deletions

View File

@ -1132,9 +1132,16 @@ bool ARMFastISel::SelectBranch(const Instruction *I) {
AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TstOpc))
.addReg(CmpReg).addImm(1));
unsigned CCMode = ARMCC::NE;
if (FuncInfo.MBB->isLayoutSuccessor(TBB)) {
std::swap(TBB, FBB);
CCMode = ARMCC::EQ;
}
unsigned BrOpc = isThumb ? ARM::t2Bcc : ARM::Bcc;
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(BrOpc))
.addMBB(TBB).addImm(ARMCC::NE).addReg(ARM::CPSR);
.addMBB(TBB).addImm(CCMode).addReg(ARM::CPSR);
FastEmitBranch(FBB, DL);
FuncInfo.MBB->addSuccessor(TBB);
return true;