summaryrefslogtreecommitdiff
path: root/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2009-11-18 03:34:27 +0000
committerBob Wilson <bob.wilson@apple.com>2009-11-18 03:34:27 +0000
commit834b08af8d3d8fc6c76ac6ca40674565689e8d7f (patch)
tree54f4512d0d88c69265505976b1d17cdd845a2fb9 /lib/CodeGen/BranchFolding.cpp
parent5eea34267376e76aceb53b6c3dfead816021258f (diff)
downloadllvm-834b08af8d3d8fc6c76ac6ca40674565689e8d7f.tar.gz
llvm-834b08af8d3d8fc6c76ac6ca40674565689e8d7f.tar.bz2
llvm-834b08af8d3d8fc6c76ac6ca40674565689e8d7f.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/BranchFolding.cpp')
-rw-r--r--lib/CodeGen/BranchFolding.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index d344af06fd..94bfb7204b 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/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.