[llvm-branch-commits] [llvm-branch] r89815 - in /llvm/branches/Apple/Zoidberg: include/llvm/Target/TargetInstrInfo.h lib/CodeGen/BranchFolding.cpp lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseInstrInfo.h
Bob Wilson
bob.wilson at apple.com
Tue Nov 24 15:37:19 PST 2009
Author: bwilson
Date: Tue Nov 24 17:37:19 2009
New Revision: 89815
URL: http://llvm.org/viewvc/llvm-project?rev=89815&view=rev
Log:
--- Merging r89814 into '.':
U include/llvm/Target/TargetInstrInfo.h
U lib/CodeGen/BranchFolding.cpp
U lib/Target/ARM/ARMBaseInstrInfo.cpp
U lib/Target/ARM/ARMBaseInstrInfo.h
Modified:
llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrInfo.h
llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp
llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.h
Modified: llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrInfo.h?rev=89815&r1=89814&r2=89815&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/Target/TargetInstrInfo.h Tue Nov 24 17:37:19 2009
@@ -544,12 +544,9 @@
virtual unsigned getInlineAsmLength(const char *Str,
const MCAsmInfo &MAI) const;
- /// TailDuplicationLimit - Returns the limit on the number of instructions
- /// in basic block MBB beyond which it will not be tail-duplicated.
- virtual unsigned TailDuplicationLimit(const MachineBasicBlock &MBB,
- unsigned DefaultLimit) const {
- return DefaultLimit;
- }
+ /// isProfitableToDuplicateIndirectBranch - Returns true if tail duplication
+ /// is especially profitable for indirect branches.
+ virtual bool isProfitableToDuplicateIndirectBranch() const { return false; }
};
/// TargetInstrInfoImpl - This is the default implementation of
Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp?rev=89815&r1=89814&r2=89815&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/BranchFolding.cpp Tue Nov 24 17:37:19 2009
@@ -1043,9 +1043,18 @@
// 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 : TII->TailDuplicationLimit(*TailBB, TailMergeSize - 1);
+ unsigned MaxDuplicateCount;
+ if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
+ MaxDuplicateCount = 1;
+ else if (TII->isProfitableToDuplicateIndirectBranch() &&
+ !TailBB->empty() && TailBB->back().getDesc().isIndirectBranch())
+ // 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.
+ MaxDuplicateCount = 20;
+ else
+ MaxDuplicateCount = TailMergeSize - 1;
// Check the instructions in the block to determine whether tail-duplication
// is invalid or unlikely to be profitable.
Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=89815&r1=89814&r2=89815&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Nov 24 17:37:19 2009
@@ -1027,14 +1027,10 @@
return TargetInstrInfoImpl::isIdentical(MI0, MI1, MRI);
}
-unsigned ARMBaseInstrInfo::TailDuplicationLimit(const MachineBasicBlock &MBB,
- unsigned DefaultLimit) const {
+bool ARMBaseInstrInfo::isProfitableToDuplicateIndirectBranch() const {
// If the target processor can predict indirect branches, it is highly
// desirable to duplicate them, since it can often make them predictable.
- if (!MBB.empty() && isIndirectBranchOpcode(MBB.back().getOpcode()) &&
- getSubtarget().hasBranchTargetBuffer())
- return DefaultLimit + 2;
- return DefaultLimit;
+ return getSubtarget().hasBranchTargetBuffer();
}
/// getInstrPredicate - If instruction is predicated, returns its predicate
Modified: llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.h?rev=89815&r1=89814&r2=89815&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.h (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/ARM/ARMBaseInstrInfo.h Tue Nov 24 17:37:19 2009
@@ -275,8 +275,7 @@
virtual bool isIdentical(const MachineInstr *MI, const MachineInstr *Other,
const MachineRegisterInfo *MRI) const;
- virtual unsigned TailDuplicationLimit(const MachineBasicBlock &MBB,
- unsigned DefaultLimit) const;
+ virtual bool isProfitableToDuplicateIndirectBranch() const;
};
static inline
More information about the llvm-branch-commits
mailing list