[llvm-commits] [llvm] r93600 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp
Bob Wilson
bob.wilson at apple.com
Fri Jan 15 16:42:26 PST 2010
Author: bwilson
Date: Fri Jan 15 18:42:25 2010
New Revision: 93600
URL: http://llvm.org/viewvc/llvm-project?rev=93600&view=rev
Log:
Treat indirect branches specially only during pre-regalloc tail duplication,
not during the later post-alloc tail duplication.
Modified:
llvm/trunk/lib/CodeGen/TailDuplication.cpp
Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=93600&r1=93599&r2=93600&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Jan 15 18:42:25 2010
@@ -433,28 +433,28 @@
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))
More information about the llvm-commits
mailing list