[llvm-commits] [llvm] r131466 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Tue May 17 09:38:37 PDT 2011
Author: stoklund
Date: Tue May 17 11:38:37 2011
New Revision: 131466
URL: http://llvm.org/viewvc/llvm-project?rev=131466&view=rev
Log:
Tweak cross-class coalescing to be more aggressive when the target class is small.
The greedy register allocator has live range splitting and register class
inflation, so it can actually fully undo this join, including restoring the
original register classes.
We still don't want to do this for long live ranges, mostly because of the high
register pressure of there are many constrained live ranges overlapping.
Modified:
llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=131466&r1=131465&r2=131466&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue May 17 11:38:37 2011
@@ -987,8 +987,14 @@
LiveInterval &DstInt = li_->getInterval(DstReg);
unsigned SrcSize = li_->getApproximateInstructionCount(SrcInt);
unsigned DstSize = li_->getApproximateInstructionCount(DstInt);
- if (SrcSize <= NewRCCount && DstSize <= NewRCCount)
+
+ // Coalesce aggressively if the intervals are small compared to the number of
+ // registers in the new class. The number 4 is fairly arbitrary, chosen to be
+ // less aggressive than the 8 used for the whole function size.
+ const unsigned ThresSize = 4 * NewRCCount;
+ if (SrcSize <= ThresSize && DstSize <= ThresSize)
return true;
+
// Estimate *register use density*. If it doubles or more, abort.
unsigned SrcUses = std::distance(mri_->use_nodbg_begin(SrcReg),
mri_->use_nodbg_end());
@@ -996,12 +1002,12 @@
mri_->use_nodbg_end());
unsigned NewUses = SrcUses + DstUses;
unsigned NewSize = SrcSize + DstSize;
- if (SrcRC != NewRC && SrcSize > NewRCCount) {
+ if (SrcRC != NewRC && SrcSize > ThresSize) {
unsigned SrcRCCount = allocatableRCRegs_[SrcRC].count();
if (NewUses*SrcSize*SrcRCCount > 2*SrcUses*NewSize*NewRCCount)
return false;
}
- if (DstRC != NewRC && DstSize > NewRCCount) {
+ if (DstRC != NewRC && DstSize > ThresSize) {
unsigned DstRCCount = allocatableRCRegs_[DstRC].count();
if (NewUses*DstSize*DstRCCount > 2*DstUses*NewSize*NewRCCount)
return false;
More information about the llvm-commits
mailing list