diff options
author | Bob Wilson <bob.wilson@apple.com> | 2009-11-18 03:34:27 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2009-11-18 03:34:27 +0000 |
commit | 290e9a47a9b31a3bfac4fcd9697d3e52f364f564 (patch) | |
tree | c9ce181a24963aebaac3ae998ccdea75253bb0a0 /llvm/lib/CodeGen/BranchFolding.cpp | |
parent | c5d2ed73ff340665a3992bc4f3e7dcf0e47e9296 (diff) | |
download | bcm5719-llvm-290e9a47a9b31a3bfac4fcd9697d3e52f364f564.tar.gz bcm5719-llvm-290e9a47a9b31a3bfac4fcd9697d3e52f364f564.zip |
Add a target hook to allow changing the tail duplication limit based on the
contents of the block to be duplicated. Use this for ARM Cortex A8/9 to
be more aggressive tail duplicating indirect branches, since it makes it
much more likely that they will be predicted in the branch target buffer.
Testcase coming soon.
llvm-svn: 89187
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index d344af06fd5..94bfb7204ba 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -1033,12 +1033,13 @@ bool BranchFolder::TailDuplicate(MachineBasicBlock *TailBB, if (TailBB->isSuccessor(TailBB)) return false; - // Duplicate up to one less than the tail-merge threshold. When optimizing - // for size, duplicate only one, because one branch instruction can be - // eliminated to compensate for the duplication. + // Set the limit on the number of instructions to duplicate, with a default + // of one less than the tail-merge threshold. When optimizing for size, + // duplicate only one, because one branch instruction can be eliminated to + // compensate for the duplication. unsigned MaxDuplicateCount = MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize) ? - 1 : (TailMergeSize - 1); + 1 : TII->TailDuplicationLimit(*TailBB, TailMergeSize - 1); // Check the instructions in the block to determine whether tail-duplication // is invalid or unlikely to be profitable. |