Don't merge in tail block of a diamond if it has more than one predecessors after...
authorEvan Cheng <evan.cheng@apple.com>
Tue, 29 May 2007 23:37:20 +0000 (23:37 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 29 May 2007 23:37:20 +0000 (23:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37353 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/IfConversion.cpp

index 8e7b0fe45a4bb743ced97d93bcf120dc1faa44bc..a57fba96fb63084584bf3be47add95b4ee440bac 100644 (file)
@@ -555,9 +555,11 @@ bool IfConverter::IfConvertDiamond(BBInfo &BBI) {
   } else
     InsertUncondBranch(BBI.BB, CvtBBI->BB, TII);
 
-  // If the if-converted block fallthrough into the tail block, then
+  // If the if-converted block fallthrough or unconditionally branch into the
+  // tail block, and the tail block does not have other predecessors, then
   // fold the tail block in as well.
-  if (BBI.TailBB && CvtBBI->BB->succ_size() == 1) {
+  if (BBI.TailBB &&
+      BBI.TailBB->succ_size() == 1 && CvtBBI->BB->succ_size() == 1) {
     CvtBBI->NonPredSize -= TII->RemoveBranch(*CvtBBI->BB);
     BBInfo TailBBI = BBAnalysis[BBI.TailBB->getNumber()];
     MergeBlocks(*CvtBBI, TailBBI);