Improve branch folding by recgonizing that explict successor relationships impact...
authorChristopher Lamb <christopher.lamb@gmail.com>
Mon, 10 Dec 2007 07:24:06 +0000 (07:24 +0000)
committerChristopher Lamb <christopher.lamb@gmail.com>
Mon, 10 Dec 2007 07:24:06 +0000 (07:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44785 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/BranchFolding.cpp
test/CodeGen/X86/2007-06-14-branchfold.ll

index d4b1e90fd54c8f530ba483edca7c8265f69a3800..0f8c6629bae086a9c5c8d885b205835301a301cb 100644 (file)
@@ -775,6 +775,11 @@ static bool IsBetterFallthrough(MachineBasicBlock *MBB1,
   // optimize branches that branch to either a return block or an assert block
   // into a fallthrough to the return.
   if (MBB1->empty() || MBB2->empty()) return false;
+  // If there is a clear successor ordering we make sure that one block
+  // will fall through to the next
+  if (MBB1->isSuccessor(MBB2)) return true;
+  if (MBB2->isSuccessor(MBB1)) return false;
 
   MachineInstr *MBB1I = --MBB1->end();
   MachineInstr *MBB2I = --MBB2->end();
index b78c63d4a3ed96aa8345b8f81e823a0b123ec2c7..697d6a34248be5bfddd240da591853509589fd58 100644 (file)
@@ -1,7 +1,5 @@
-; RUN: llvm-as < %s | llc -mcpu=i686 | grep jmp | count 1
+; RUN: llvm-as < %s | llc -mcpu=i686 | not grep jmp
 ; check that branch folding understands FP_REG_KILL is not a branch
-; the remaining jmp can be removed if we take advantage of knowing
-; abort does not return
 
 ; ModuleID = 'g.bc'
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"