[llvm-commits] [llvm] r129187 - in /llvm/trunk/lib/CodeGen: InterferenceCache.cpp InterferenceCache.h
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Apr 8 19:59:05 PDT 2011
Author: stoklund
Date: Fri Apr 8 21:59:05 2011
New Revision: 129187
URL: http://llvm.org/viewvc/llvm-project?rev=129187&view=rev
Log:
Precompute interference for neighbor blocks as long as there is no interference.
This doesn't require seeking in the live interval union, so it is very cheap.
Modified:
llvm/trunk/lib/CodeGen/InterferenceCache.cpp
llvm/trunk/lib/CodeGen/InterferenceCache.h
Modified: llvm/trunk/lib/CodeGen/InterferenceCache.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InterferenceCache.cpp?rev=129187&r1=129186&r2=129187&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InterferenceCache.cpp (original)
+++ llvm/trunk/lib/CodeGen/InterferenceCache.cpp Fri Apr 8 21:59:05 2011
@@ -26,7 +26,7 @@
TRI = tri;
PhysRegEntries.assign(TRI->getNumRegs(), 0);
for (unsigned i = 0; i != CacheEntries; ++i)
- Entries[i].clear(indexes);
+ Entries[i].clear(mf, indexes);
}
InterferenceCache::Entry *InterferenceCache::get(unsigned PhysReg) {
@@ -91,10 +91,6 @@
}
void InterferenceCache::Entry::update(unsigned MBBNum) {
- BlockInterference *BI = &Blocks[MBBNum];
- BI->Tag = Tag;
- BI->First = BI->Last = SlotIndex();
-
SlotIndex Start, Stop;
tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
@@ -109,23 +105,39 @@
PrevPos = Start;
}
- // Check for first interference.
- for (unsigned i = 0, e = Iters.size(); i != e; ++i) {
- Iter &I = Iters[i];
- if (!I.valid())
- continue;
- SlotIndex StartI = I.start();
- if (StartI >= Stop)
- continue;
- if (!BI->First.isValid() || StartI < BI->First)
- BI->First = StartI;
+ MachineFunction::const_iterator MFI = MF->getBlockNumbered(MBBNum);
+ BlockInterference *BI = &Blocks[MBBNum];
+ for (;;) {
+ BI->Tag = Tag;
+ BI->First = BI->Last = SlotIndex();
+
+ // Check for first interference.
+ for (unsigned i = 0, e = Iters.size(); i != e; ++i) {
+ Iter &I = Iters[i];
+ if (!I.valid())
+ continue;
+ SlotIndex StartI = I.start();
+ if (StartI >= Stop)
+ continue;
+ if (!BI->First.isValid() || StartI < BI->First)
+ BI->First = StartI;
+ }
+
+ PrevPos = Stop;
+ if (BI->First.isValid())
+ break;
+
+ // No interference in this block? Go ahead and precompute the next block.
+ if (++MFI == MF->end())
+ return;
+ MBBNum = MFI->getNumber();
+ BI = &Blocks[MBBNum];
+ if (BI->Tag == Tag)
+ return;
+ tie(Start, Stop) = Indexes->getMBBRange(MBBNum);
}
- // No interference in block.
- if (!BI->First.isValid())
- return;
-
- // Check for last interference.
+ // Check for last interference in block.
for (unsigned i = 0, e = Iters.size(); i != e; ++i) {
Iter &I = Iters[i];
if (!I.valid() || I.start() >= Stop)
@@ -140,5 +152,4 @@
if (Backup)
++I;
}
- PrevPos = Stop;
}
Modified: llvm/trunk/lib/CodeGen/InterferenceCache.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InterferenceCache.h?rev=129187&r1=129186&r2=129187&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InterferenceCache.h (original)
+++ llvm/trunk/lib/CodeGen/InterferenceCache.h Fri Apr 8 21:59:05 2011
@@ -43,6 +43,9 @@
/// change.
unsigned Tag;
+ /// MF - The current function.
+ MachineFunction *MF;
+
/// Indexes - Mapping block numbers to SlotIndex ranges.
SlotIndexes *Indexes;
@@ -67,8 +70,9 @@
public:
Entry() : PhysReg(0), Tag(0), Indexes(0) {}
- void clear(SlotIndexes *indexes) {
+ void clear(MachineFunction *mf, SlotIndexes *indexes) {
PhysReg = 0;
+ MF = mf;
Indexes = indexes;
}
More information about the llvm-commits
mailing list