diff options
author | Evan Cheng <evan.cheng@apple.com> | 2011-05-11 01:03:01 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2011-05-11 01:03:01 +0000 |
commit | 05fc35e275529eddb6c73bed7595bd7cec93f27a (patch) | |
tree | fc85d3171c18033d0c423f5fca9bc627faa4ef05 /llvm/lib/CodeGen/BranchFolding.h | |
parent | 4a34e61e53b4a87365b0352256735e104b84d055 (diff) | |
download | bcm5719-llvm-05fc35e275529eddb6c73bed7595bd7cec93f27a.tar.gz bcm5719-llvm-05fc35e275529eddb6c73bed7595bd7cec93f27a.zip |
Add a late optimization to BranchFolding that hoist common instruction sequences
at the start of basic blocks to their common predecessor. It's actually quite
common (e.g. about 50 times in JM/lencod) and has shown to be a nice code size
benefit. e.g.
pushq %rax
testl %edi, %edi
jne LBB0_2
## BB#1:
xorb %al, %al
popq %rdx
ret
LBB0_2:
xorb %al, %al
callq _foo
popq %rdx
ret
=>
pushq %rax
xorb %al, %al
testl %edi, %edi
je LBB0_2
## BB#1:
callq _foo
LBB0_2:
popq %rdx
ret
rdar://9145558
llvm-svn: 131172
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.h')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.h b/llvm/lib/CodeGen/BranchFolding.h index 15dfa7f6bee..4daf4ecfe59 100644 --- a/llvm/lib/CodeGen/BranchFolding.h +++ b/llvm/lib/CodeGen/BranchFolding.h @@ -19,11 +19,10 @@ namespace llvm { class RegScavenger; class TargetInstrInfo; class TargetRegisterInfo; - template<typename T> class SmallVectorImpl; class BranchFolder { public: - explicit BranchFolder(bool defaultEnableTailMerge); + explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist); bool OptimizeFunction(MachineFunction &MF, const TargetInstrInfo *tii, @@ -85,6 +84,7 @@ namespace llvm { std::vector<SameTailElt> SameTails; bool EnableTailMerge; + bool EnableHoistCommonCode; const TargetInstrInfo *TII; const TargetRegisterInfo *TRI; MachineModuleInfo *MMI; @@ -110,6 +110,9 @@ namespace llvm { bool OptimizeBlock(MachineBasicBlock *MBB); void RemoveDeadBlock(MachineBasicBlock *MBB); bool OptimizeImpDefsBlock(MachineBasicBlock *MBB); + + bool HoistCommonCode(MachineFunction &MF); + bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB); }; } |