diff options
author | Christopher Lamb <christopher.lamb@gmail.com> | 2007-12-10 07:24:06 +0000 |
---|---|---|
committer | Christopher Lamb <christopher.lamb@gmail.com> | 2007-12-10 07:24:06 +0000 |
commit | 11a4f64bd4cb6d438dd4b5882ee1b7404832f27f (patch) | |
tree | 269a1e0d787265ac3f793513d1320da8ee4f7379 | |
parent | 53c34b1db978f1820677f410c6f3f59046ffa4c0 (diff) | |
download | external_llvm-11a4f64bd4cb6d438dd4b5882ee1b7404832f27f.zip external_llvm-11a4f64bd4cb6d438dd4b5882ee1b7404832f27f.tar.gz external_llvm-11a4f64bd4cb6d438dd4b5882ee1b7404832f27f.tar.bz2 |
Improve branch folding by recgonizing that explict successor relationships impact the value of fall-through choices.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44785 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/BranchFolding.cpp | 5 | ||||
-rw-r--r-- | test/CodeGen/X86/2007-06-14-branchfold.ll | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index d4b1e90..0f8c662 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -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(); diff --git a/test/CodeGen/X86/2007-06-14-branchfold.ll b/test/CodeGen/X86/2007-06-14-branchfold.ll index b78c63d..697d6a3 100644 --- a/test/CodeGen/X86/2007-06-14-branchfold.ll +++ b/test/CodeGen/X86/2007-06-14-branchfold.ll @@ -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" |