@@ -2804,103 +2804,9 @@ void SpillManagerGRF::insertSpillRangeCode(
2804
2804
return ;
2805
2805
}
2806
2806
2807
- auto IsUniqueDef = [this , inst, 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].size () != 1 )
2812
- {
2813
- // check whether multiple defs exist in program for current
2814
- // lb, rb
2815
- auto lb = inst->getDst ()->getLeftBound ();
2816
- auto rb = inst->getDst ()->getRightBound ();
2817
- unsigned int count = 0 ;
2818
- auto & defs = VarDefs[spillDcl];
2819
- for (auto & def : defs)
2820
- {
2821
- if (def.first <= rb &&
2822
- def.second >= lb)
2823
- ++count;
2824
- }
2825
-
2826
- if (count > 1 )
2827
- return false ;
2828
- }
2829
-
2830
- // check whether variable is live-in to BB
2831
- if (lvInfo_->isLiveAtEntry (bb, spillDcl->getRegVar ()->getId ()))
2832
- return false ;
2833
-
2834
- return true ;
2835
- };
2836
-
2837
- auto PseudoKillFound = [spilledInstIter, bb, spillDcl]()
2838
- {
2839
- // Search upwards from spilledInstIter to find a pseudo kill.
2840
- // Return true if one is found, false otherwise.
2841
- // When a pseudo kill is found, it means read-modify-write is
2842
- // not needed.
2843
- auto bbBegin = bb->begin ();
2844
- if (spilledInstIter == bbBegin)
2845
- return false ;
2846
- auto it = spilledInstIter;
2847
- --it;
2848
- while (it != bbBegin)
2849
- {
2850
- auto inst = *it;
2851
- // check if adjacent instruction is a pseudo kill
2852
- if (inst->isPseudoKill ())
2853
- {
2854
- if (inst->getDst ()->getTopDcl () == spillDcl)
2855
- return true ;
2856
- }
2857
- else
2858
- {
2859
- auto dst = inst->getDst ();
2860
- if (!dst)
2861
- return false ;
2862
-
2863
- // recognize pattern where V10 is spilled:
2864
- // pseudo_kill V10
2865
- // op (8) V10(0,0) ...
2866
- // op (8) V10(2,0) ... <-- Current inst
2867
- //
2868
- // becomes:
2869
- // pseudo_kill V10
2870
- // op (8) SP_V10(0,0) ... [2]
2871
- // intrinsic_spill (8) ... SP_V10 ... [1]
2872
- // op (8) V10(2,0) <-- Current inst
2873
- if (inst->isSpillIntrinsic () &&
2874
- inst->asSpillIntrinsic ()->getPayload () &&
2875
- inst->asSpillIntrinsic ()->getPayload ()->getTopDcl ()->getRegVar ()->isRegVarTransient ())
2876
- {
2877
- auto spillBase = ((G4_RegVarTransient*)inst->asSpillIntrinsic ()->getPayload ()->getTopDcl ()->getRegVar ())->getAbsBaseRegVar ();
2878
- if (spillBase->getDeclare ()->getRootDeclare () != spillDcl)
2879
- return false ;
2880
- // Fall through for instruction [1] above
2881
- }
2882
- else if (dst &&
2883
- dst->getTopDcl () &&
2884
- dst->getTopDcl ()->getRegVar ()->isRegVarTransient ())
2885
- {
2886
- auto spillBase = ((G4_RegVarTransient*)dst->getTopDcl ()->getRegVar ())->getAbsBaseRegVar ();
2887
- if (spillBase->getDeclare ()->getRootDeclare () != spillDcl)
2888
- return false ;
2889
- // Fall through for instruction [2] above
2890
- }
2891
- else if (inst->getDst ()->getTopDcl () != spillDcl)
2892
- return false ;
2893
- }
2894
- --it;
2895
- }
2896
- return false ;
2897
- };
2898
-
2899
2807
// subreg offset for new dst that replaces the spilled dst
2900
2808
auto newSubregOff = 0 ;
2901
2809
2902
- auto pseudoKillFound = PseudoKillFound ();
2903
- auto isUniqueDef = IsUniqueDef ();
2904
2810
if (inst->mayExceedTwoGRF ())
2905
2811
{
2906
2812
// Handle send instructions (special treatment)
@@ -2915,9 +2821,7 @@ void SpillManagerGRF::insertSpillRangeCode(
2915
2821
createAndInitMHeader (
2916
2822
(G4_RegVarTransient *) spillRangeDcl->getRegVar ());
2917
2823
2918
- bool needRMW = !pseudoKillFound &&
2919
- !isUniqueDef &&
2920
- inst->isPartialWriteForSpill (!bb->isAllLaneActive ());
2824
+ bool needRMW = inst->isPartialWriteForSpill (!bb->isAllLaneActive ());
2921
2825
if (needRMW)
2922
2826
{
2923
2827
sendInSpilledRegVarPortions (
@@ -2952,9 +2856,7 @@ void SpillManagerGRF::insertSpillRangeCode(
2952
2856
2953
2857
// Unaligned region specific handling.
2954
2858
unsigned int spillSendOption = InstOpt_WriteEnable;
2955
- if (!pseudoKillFound &&
2956
- !isUniqueDef &&
2957
- shouldPreloadSpillRange (*spilledInstIter, bb)) {
2859
+ if (shouldPreloadSpillRange (*spilledInstIter, bb)) {
2958
2860
2959
2861
// Preload the segment aligned spill range from memory to use
2960
2862
// as an overlay
@@ -3036,13 +2938,7 @@ void SpillManagerGRF::insertSpillRangeCode(
3036
2938
newSubregOff = spilledRegion->getSubRegOff ();
3037
2939
if (!bb->isAllLaneActive ())
3038
2940
{
3039
- if (!pseudoKillFound &&
3040
- !isUniqueDef)
3041
- {
3042
- // If either pseudo kill is found or if the range is a unique def,
3043
- // use WriteEnable option in spill.
3044
- spillSendOption = (*spilledInstIter)->getMaskOption ();
3045
- }
2941
+ spillSendOption = (*spilledInstIter)->getMaskOption ();
3046
2942
}
3047
2943
}
3048
2944
@@ -3977,33 +3873,6 @@ void SpillManagerGRF::runSpillAnalysis()
3977
3873
}
3978
3874
}
3979
3875
3980
- void SpillManagerGRF::populateDefsTable ()
3981
- {
3982
- for (auto bb : gra.kernel .fg )
3983
- {
3984
- for (auto inst : *bb)
3985
- {
3986
- if (inst->isPseudoKill ())
3987
- continue ;
3988
-
3989
- auto dst = inst->getDst ();
3990
-
3991
- if (dst && !dst->isNullReg ())
3992
- {
3993
- auto topdcl = dst->getTopDcl ();
3994
-
3995
- if (topdcl)
3996
- {
3997
- auto lb = dst->getLeftBound ();
3998
- auto rb = dst->getRightBound ();
3999
- VarDefs[topdcl].push_back (std::make_pair (lb, rb));
4000
- }
4001
- }
4002
- }
4003
- }
4004
- }
4005
-
4006
-
4007
3876
// Insert spill/fill code for all registers that have not been assigned
4008
3877
// physical registers in the current iteration of the graph coloring
4009
3878
// allocator.
@@ -4044,9 +3913,6 @@ bool SpillManagerGRF::insertSpillFillCode (
4044
3913
return false ;
4045
3914
}
4046
3915
4047
- // Populate def table as it helps us decide whether read-modify-write is needed
4048
- populateDefsTable ();
4049
-
4050
3916
// Insert spill/fill code for all basic blocks.
4051
3917
4052
3918
FlowGraph& fg = kernel->fg ;
@@ -4055,7 +3921,6 @@ bool SpillManagerGRF::insertSpillFillCode (
4055
3921
{
4056
3922
bbId_ = (*it)->getId ();
4057
3923
INST_LIST::iterator jt = (*it)->begin ();
4058
- std::list<INST_LIST_ITER> pseudoKills;
4059
3924
4060
3925
while (jt != (*it)->end ()) {
4061
3926
INST_LIST::iterator kt = jt;
@@ -4085,11 +3950,7 @@ bool SpillManagerGRF::insertSpillFillCode (
4085
3950
{
4086
3951
if (inst->isPseudoKill ())
4087
3952
{
4088
- // This pseudo kill corresponds to a spilled variable, so
4089
- // it can be removed. But it is preserved till spill code
4090
- // is inserted for the variable as it provides a hint to
4091
- // spill insertion that read-modify-write is not needed.
4092
- pseudoKills.push_back (jt);
3953
+ (*it)->erase (jt);
4093
3954
jt = kt;
4094
3955
continue ;
4095
3956
}
@@ -4142,11 +4003,6 @@ bool SpillManagerGRF::insertSpillFillCode (
4142
4003
4143
4004
jt = kt;
4144
4005
}
4145
-
4146
- for (auto killIt : pseudoKills)
4147
- {
4148
- (*it)->erase (killIt);
4149
- }
4150
4006
}
4151
4007
4152
4008
bbId_ = UINT_MAX;
0 commit comments