Skip to content

Commit 67d5a14

Browse files
pratikasharigcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: a1a03dc
Dont add fill for spilled variables that have a single def in program and are not live-in to the BB, hence not loop carried. definition. Such variables dont need read-modify-write when spilled.
1 parent e80b105 commit 67d5a14

File tree

2 files changed

+3
-90
lines changed

2 files changed

+3
-90
lines changed

visa/SpillManagerGMRF.cpp

Lines changed: 3 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,47 +2804,6 @@ void SpillManagerGRF::insertSpillRangeCode(
28042804
return;
28052805
}
28062806

2807-
auto IsUniqueDef = [this, bb, spillDcl]()
2808-
{
2809-
// return true if spilled variable has a single def
2810-
// and it is not live-in to current bb (eg, loop, sub).
2811-
if (VarDefs[spillDcl] != 1)
2812-
return false;
2813-
2814-
// check whether variable is live-in to BB
2815-
if (lvInfo_->isLiveAtEntry(bb, spillDcl->getRegVar()->getId()))
2816-
return false;
2817-
2818-
return true;
2819-
};
2820-
2821-
auto PseudoKillFound = [spilledInstIter, bb, spillDcl]()
2822-
{
2823-
// Search upwards from spilledInstIter to find a pseudo kill.
2824-
// Return true if one is found, false otherwise.
2825-
// When a pseudo kill is found, it means read-modify-write is
2826-
// not needed.
2827-
auto bbBegin = bb->begin();
2828-
if (spilledInstIter == bbBegin)
2829-
return false;
2830-
auto it = spilledInstIter;
2831-
--it;
2832-
while (it != bbBegin)
2833-
{
2834-
auto inst = *it;
2835-
// check if adjacent instruction is a pseudo kill
2836-
if (inst->isPseudoKill())
2837-
{
2838-
if (inst->getDst()->getTopDcl() == spillDcl)
2839-
return true;
2840-
}
2841-
else
2842-
return false;
2843-
--it;
2844-
}
2845-
return false;
2846-
};
2847-
28482807
//subreg offset for new dst that replaces the spilled dst
28492808
auto newSubregOff = 0;
28502809

@@ -2862,9 +2821,7 @@ void SpillManagerGRF::insertSpillRangeCode(
28622821
createAndInitMHeader (
28632822
(G4_RegVarTransient *) spillRangeDcl->getRegVar());
28642823

2865-
bool needRMW = !PseudoKillFound() &&
2866-
!IsUniqueDef() &&
2867-
inst->isPartialWriteForSpill(!bb->isAllLaneActive());
2824+
bool needRMW = inst->isPartialWriteForSpill(!bb->isAllLaneActive());
28682825
if (needRMW)
28692826
{
28702827
sendInSpilledRegVarPortions(
@@ -2899,9 +2856,7 @@ void SpillManagerGRF::insertSpillRangeCode(
28992856

29002857
// Unaligned region specific handling.
29012858
unsigned int spillSendOption = InstOpt_WriteEnable;
2902-
if (!PseudoKillFound() &&
2903-
!IsUniqueDef() &&
2904-
shouldPreloadSpillRange(*spilledInstIter, bb)) {
2859+
if (shouldPreloadSpillRange(*spilledInstIter, bb)) {
29052860

29062861
// Preload the segment aligned spill range from memory to use
29072862
// as an overlay
@@ -3918,31 +3873,6 @@ void SpillManagerGRF::runSpillAnalysis()
39183873
}
39193874
}
39203875

3921-
void SpillManagerGRF::populateDefsTable()
3922-
{
3923-
for (auto bb : gra.kernel.fg)
3924-
{
3925-
for (auto inst : *bb)
3926-
{
3927-
if (inst->isPseudoKill())
3928-
continue;
3929-
3930-
auto dst = inst->getDst();
3931-
3932-
if (dst && !dst->isNullReg())
3933-
{
3934-
auto topdcl = dst->getTopDcl();
3935-
3936-
if (topdcl)
3937-
{
3938-
VarDefs[topdcl] += 1;
3939-
}
3940-
}
3941-
}
3942-
}
3943-
}
3944-
3945-
39463876
// Insert spill/fill code for all registers that have not been assigned
39473877
// physical registers in the current iteration of the graph coloring
39483878
// allocator.
@@ -3983,9 +3913,6 @@ bool SpillManagerGRF::insertSpillFillCode (
39833913
return false;
39843914
}
39853915

3986-
// Populate def table as it helps us decide whether read-modify-write is needed
3987-
populateDefsTable();
3988-
39893916
// Insert spill/fill code for all basic blocks.
39903917

39913918
FlowGraph& fg = kernel->fg;
@@ -3994,7 +3921,6 @@ bool SpillManagerGRF::insertSpillFillCode (
39943921
{
39953922
bbId_ = (*it)->getId();
39963923
INST_LIST::iterator jt = (*it)->begin();
3997-
std::list<INST_LIST_ITER> pseudoKills;
39983924

39993925
while (jt != (*it)->end()) {
40003926
INST_LIST::iterator kt = jt;
@@ -4024,11 +3950,7 @@ bool SpillManagerGRF::insertSpillFillCode (
40243950
{
40253951
if (inst->isPseudoKill())
40263952
{
4027-
// This pseudo kill corresponds to a spilled variable, so
4028-
// it can be removed. But it is preserved till spill code
4029-
// is inserted for the variable as it provides a hint to
4030-
// spill insertion that read-modify-write is not needed.
4031-
pseudoKills.push_back(jt);
3953+
(*it)->erase(jt);
40323954
jt = kt;
40333955
continue;
40343956
}
@@ -4081,11 +4003,6 @@ bool SpillManagerGRF::insertSpillFillCode (
40814003

40824004
jt = kt;
40834005
}
4084-
4085-
for(auto killIt : pseudoKills)
4086-
{
4087-
(*it)->erase(killIt);
4088-
}
40894006
}
40904007

40914008
bbId_ = UINT_MAX;

visa/SpillManagerGMRF.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,6 @@ class SpillManagerGRF
593593
}
594594
}
595595

596-
void populateDefsTable();
597-
598596
// Data
599597
GlobalRA& gra;
600598
IR_Builder * builder_;
@@ -625,8 +623,6 @@ class SpillManagerGRF
625623
const Interference * spillIntf_;
626624
vISA::Mem_Manager mem_;
627625

628-
std::unordered_map<G4_Declare*, unsigned int> VarDefs;
629-
630626
// The number of GRF spill.
631627
unsigned numGRFSpill = 0;
632628

0 commit comments

Comments
 (0)