Handle blocks with 2 unconditional branches in AnalyzeBranch.
authorDale Johannesen <dalej@apple.com>
Wed, 13 Jun 2007 17:59:52 +0000 (17:59 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 13 Jun 2007 17:59:52 +0000 (17:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37571 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMInstrInfo.cpp
lib/Target/Alpha/AlphaInstrInfo.cpp
lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/X86/X86InstrInfo.cpp

index e9c57b25e48ddded72b20c4799697d95d9a1e0e0..1370faba4d7c9e592f4679bb4f9732b602a73f49 100644 (file)
@@ -345,6 +345,16 @@ bool ARMInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
     return false;
   }
   
+  // If the block ends with two B's or tB's, handle it.  The second one is not
+  // executed, so remove it.
+  if ((SecondLastOpc == ARM::B || SecondLastOpc==ARM::tB) &&
+      (LastOpc == ARM::B || LastOpc == ARM::tB)) {
+    TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
+    I = LastInst;
+    I->eraseFromParent();
+    return false;
+  }
+
   // Otherwise, can't handle this.
   return true;
 }
index 15f5f841bc3fa8164dc0e43facdc0b977290d9eb..718587dd2924c8136fb47366be0ef77267a92f5a 100644 (file)
@@ -200,6 +200,16 @@ bool AlphaInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TB
     return false;
   }
   
+  // If the block ends with two Alpha::BRs, handle it.  The second one is not
+  // executed, so remove it.
+  if (SecondLastInst->getOpcode() == Alpha::BR && 
+      LastInst->getOpcode() == Alpha::BR) {
+    TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
+    I = LastInst;
+    I->eraseFromParent();
+    return false;
+  }
+
   // Otherwise, can't handle this.
   return true;
 }
index 1ec9e6013876564fb7722077918d303696b4613b..d7ee5ed04e8beff779a8be156556093855fa5b33 100644 (file)
@@ -220,6 +220,16 @@ bool PPCInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
     return false;
   }
   
+  // If the block ends with two PPC:Bs, handle it.  The second one is not
+  // executed, so remove it.
+  if (SecondLastInst->getOpcode() == PPC::B && 
+      LastInst->getOpcode() == PPC::B) {
+    TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
+    I = LastInst;
+    I->eraseFromParent();
+    return false;
+  }
+
   // Otherwise, can't handle this.
   return true;
 }
index a3b3223611e016271b2203bb5d5981762bb21eef..57282d471fc13b5ece926d04b1dee7924c4fb3d9 100644 (file)
@@ -427,6 +427,16 @@ bool X86InstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
     return false;
   }
 
+  // If the block ends with two X86::JMPs, handle it.  The second one is not
+  // executed, so remove it.
+  if (SecondLastInst->getOpcode() == X86::JMP && 
+      LastInst->getOpcode() == X86::JMP) {
+    TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
+    I = LastInst;
+    I->eraseFromParent();
+    return false;
+  }
+
   // Otherwise, can't handle this.
   return true;
 }