Skip to content

Commit 6b0689d

Browse files
pratikasharigcbot
authored andcommitted
Avoid O(n^2) iteration over kernel declares.
1 parent 562c0d5 commit 6b0689d

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

visa/GraphColor.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,45 @@ void Interference::addCalleeSaveBias(const BitSet& live)
17821782
}
17831783
}
17841784

1785+
void Interference::buildInterferenceAmongLiveOuts()
1786+
{
1787+
// Mark interference between dcls marked as Output.
1788+
//
1789+
// Interference computation marks interference for a
1790+
// variable only when definition for that variable is
1791+
// seen, not otherwise.
1792+
//
1793+
// This method is useful when definition of such
1794+
// "Output" variables are emitted to program post RA.
1795+
//
1796+
// It is safe to mark interference between all "Output"
1797+
// dcls even when their definition is present in the program.
1798+
1799+
// First gather all Output dcls in a vector to avoid an O(N^2)
1800+
// lookup. Number of OutputDcls should be small.
1801+
std::vector<G4_Declare*> OutputDcls;
1802+
for (auto dcl : kernel.Declares)
1803+
{
1804+
if (!dcl->getRegVar()->isRegAllocPartaker() ||
1805+
!dcl->isOutput())
1806+
continue;
1807+
1808+
OutputDcls.push_back(dcl);
1809+
}
1810+
1811+
for (auto dcl1 : OutputDcls)
1812+
{
1813+
// dcl1 is RA partaker iter and is marked as Output
1814+
for (auto dcl2 : OutputDcls)
1815+
{
1816+
if (dcl1 == dcl2)
1817+
continue;
1818+
1819+
checkAndSetIntf(dcl1->getRegVar()->getId(), dcl2->getRegVar()->getId());
1820+
}
1821+
}
1822+
}
1823+
17851824
void Interference::buildInterferenceAmongLiveIns()
17861825
{
17871826
//
@@ -2448,6 +2487,8 @@ void Interference::computeInterference()
24482487
//
24492488
BitSet live(maxId, false);
24502489

2490+
buildInterferenceAmongLiveOuts();
2491+
24512492
for (G4_BB *bb : kernel.fg)
24522493
{
24532494
//

visa/GraphColor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ namespace vISA
446446

447447
void buildInterferenceWithLocalRA(G4_BB* bb);
448448

449+
void buildInterferenceAmongLiveOuts();
449450
void buildInterferenceAmongLiveIns();
450451

451452
void markInterferenceToAvoidDstSrcOverlap(G4_BB* bb, G4_INST* inst);

visa/SpillManagerGMRF.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4710,6 +4710,7 @@ void GlobalRA::expandFillStackcall(uint32_t numRows, uint32_t offset, short rowO
47104710
}
47114711
}
47124712

4713+
47134714
void GlobalRA::expandFillIntrinsic(G4_BB* bb)
47144715
{
47154716
// fill (1) fill_var:ud bitmask:ud offset:ud

0 commit comments

Comments
 (0)