summaryrefslogtreecommitdiff
path: root/lib/CodeGen/TailDuplication.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-01-16 00:42:25 +0000
committerBob Wilson <bob.wilson@apple.com>2010-01-16 00:42:25 +0000
commitcb44b28f4d96c059d30c1a77d3b7e406d362d94e (patch)
treed325d47f0b54144e90b2ad3488ac9fee2337d9ea /lib/CodeGen/TailDuplication.cpp
parent551cdd56ce7225e62334813bb485e8e7174c336b (diff)
downloadllvm-cb44b28f4d96c059d30c1a77d3b7e406d362d94e.tar.gz
llvm-cb44b28f4d96c059d30c1a77d3b7e406d362d94e.tar.bz2
llvm-cb44b28f4d96c059d30c1a77d3b7e406d362d94e.tar.xz
Treat indirect branches specially only during pre-regalloc tail duplication,
not during the later post-alloc tail duplication. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93600 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TailDuplication.cpp')
-rw-r--r--lib/CodeGen/TailDuplication.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/CodeGen/TailDuplication.cpp b/lib/CodeGen/TailDuplication.cpp
index a2af8b3b7d..d6860bcd17 100644
--- a/lib/CodeGen/TailDuplication.cpp
+++ b/lib/CodeGen/TailDuplication.cpp
@@ -433,28 +433,28 @@ bool
TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, MachineFunction &MF,
SmallVector<MachineBasicBlock*, 8> &TDBBs,
SmallVector<MachineInstr*, 16> &Copies) {
- // Pre-regalloc tail duplication hurts compile time and doesn't help
- // much except for indirect branches.
- bool hasIndirectBranch = (!TailBB->empty() &&
- TailBB->back().getDesc().isIndirectBranch());
- if (PreRegAlloc && !hasIndirectBranch)
- return false;
-
// 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;
- if (hasIndirectBranch)
+ if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
+ MaxDuplicateCount = 1;
+ else
+ MaxDuplicateCount = TailDuplicateSize;
+
+ if (PreRegAlloc) {
+ // Pre-regalloc tail duplication hurts compile time and doesn't help
+ // much except for indirect branches.
+ if (TailBB->empty() || !TailBB->back().getDesc().isIndirectBranch())
+ return false;
// If the target has hardware branch prediction that can handle indirect
// branches, duplicating them can often make them predictable when there
// are common paths through the code. The limit needs to be high enough
- // to allow undoing the effects of tail merging.
+ // to allow undoing the effects of tail merging and other optimizations
+ // that rearrange the predecessors of the indirect branch.
MaxDuplicateCount = 20;
- else if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
- MaxDuplicateCount = 1;
- else
- MaxDuplicateCount = TailDuplicateSize;
+ }
// Don't try to tail-duplicate single-block loops.
if (TailBB->isSuccessor(TailBB))