@@ -6103,129 +6103,8 @@ void GraphColor::computeDegreeForARF()
6103
6103
6104
6104
void GraphColor::computeSpillCosts (bool useSplitLLRHeuristic)
6105
6105
{
6106
- std::vector <LiveRange*> addressSensitiveVars;
6106
+ std::vector <LiveRange *> addressSensitiveVars;
6107
6107
float maxNormalCost = 0 .0f ;
6108
- VarReferences directRefs (kernel);
6109
- std::list<std::pair<G4_INST*, G4_BB*>> indirectRefs;
6110
-
6111
- if (liveAnalysis.livenessClass (G4_GRF))
6112
- {
6113
- // gather all instructions with indirect operands
6114
- // for ref count computation once.
6115
- for (auto bb : kernel.fg .getBBList ())
6116
- {
6117
- for (auto inst : bb->getInstList ())
6118
- {
6119
- auto dst = inst->getDst ();
6120
- if (dst && dst->isIndirect ())
6121
- {
6122
- indirectRefs.push_back (std::make_pair (inst, bb));
6123
- continue ;
6124
- }
6125
-
6126
- for (unsigned int i = 0 ; i != inst->getNumSrc (); ++i)
6127
- {
6128
- auto src = inst->getSrc (i);
6129
- if (!src || !src->isSrcRegRegion () || !src->asSrcRegRegion ()->isIndirect ())
6130
- {
6131
- continue ;
6132
- }
6133
- indirectRefs.push_back (std::make_pair (inst, bb));
6134
- continue ;
6135
- }
6136
- }
6137
- }
6138
- }
6139
-
6140
- auto getWeightedRefCount = [&](G4_Declare* dcl, unsigned int useWt = 1 , unsigned int defWt = 1 )
6141
- {
6142
- auto defs = directRefs.getDefs (dcl);
6143
- auto uses = directRefs.getUses (dcl);
6144
- auto & loops = kernel.fg .getLoops ();
6145
-
6146
- unsigned int refCount = 0 ;
6147
- const unsigned int assumeLoopIter = 10 ;
6148
-
6149
- if (defs)
6150
- {
6151
- for (auto def : *defs)
6152
- {
6153
- auto * bb = std::get<1 >(def);
6154
- auto * innerMostLoop = loops.getInnerMostLoop (bb);
6155
- if (innerMostLoop)
6156
- {
6157
- auto nestingLevel = innerMostLoop->getNestingLevel ();
6158
- refCount += (unsigned int )std::pow (assumeLoopIter, nestingLevel);
6159
- }
6160
- else
6161
- refCount += defWt;
6162
- }
6163
- }
6164
-
6165
- if (uses)
6166
- {
6167
- for (auto use : *uses)
6168
- {
6169
- auto * bb = std::get<1 >(use);
6170
- auto * innerMostLoop = loops.getInnerMostLoop (bb);
6171
- if (innerMostLoop)
6172
- {
6173
- auto nestingLevel = innerMostLoop->getNestingLevel ();
6174
- refCount += (unsigned int )std::pow (assumeLoopIter, nestingLevel);
6175
- }
6176
- else
6177
- refCount += useWt;
6178
- }
6179
- }
6180
-
6181
- if (dcl->getAddressed ())
6182
- {
6183
- for (auto & item : indirectRefs)
6184
- {
6185
- auto inst = item.first ;
6186
- auto bb = item.second ;
6187
-
6188
- auto dst = inst->getDst ();
6189
- if (dst && dst->isIndirect ())
6190
- {
6191
- if (liveAnalysis.getPointsToAnalysis ().isPresentInPointsTo (dst->getTopDcl ()->getRegVar (), dcl->getRegVar ()))
6192
- {
6193
- auto * innerMostLoop = loops.getInnerMostLoop (bb);
6194
- if (innerMostLoop)
6195
- {
6196
- auto nestingLevel = innerMostLoop->getNestingLevel ();
6197
- refCount += (unsigned int )std::pow (assumeLoopIter, nestingLevel);
6198
- }
6199
- else
6200
- refCount += useWt;
6201
- }
6202
- }
6203
-
6204
- for (unsigned int i = 0 ; i != inst->getNumSrc (); ++i)
6205
- {
6206
- auto src = inst->getSrc (i);
6207
- if (!src || !src->isSrcRegRegion () || !src->asSrcRegRegion ()->isIndirect ())
6208
- {
6209
- continue ;
6210
- }
6211
- if (liveAnalysis.getPointsToAnalysis ().isPresentInPointsTo (src->asSrcRegRegion ()->getTopDcl ()->getRegVar (), dcl->getRegVar ()))
6212
- {
6213
- auto * innerMostLoop = loops.getInnerMostLoop (bb);
6214
- if (innerMostLoop)
6215
- {
6216
- auto nestingLevel = innerMostLoop->getNestingLevel ();
6217
- refCount += (unsigned int )std::pow (assumeLoopIter, nestingLevel);
6218
- }
6219
- else
6220
- refCount += useWt;
6221
- }
6222
- }
6223
-
6224
- }
6225
- }
6226
-
6227
- return refCount == 0 ? 1 : refCount;
6228
- };
6229
6108
6230
6109
auto incSpillCostCandidate = [&](LiveRange* lr)
6231
6110
{
@@ -6237,7 +6116,7 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
6237
6116
6238
6117
// this condition is a safety measure and isnt expected to be true.
6239
6118
auto it = revAddrTakenMap.find (lr->getDcl ());
6240
- if (it == revAddrTakenMap.end ())
6119
+ if (it == revAddrTakenMap.end ())
6241
6120
return true ;
6242
6121
6243
6122
for (auto & addrVar : (*it).second )
@@ -6315,43 +6194,22 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
6315
6194
{
6316
6195
if (useSplitLLRHeuristic)
6317
6196
{
6318
- spillCost = 1 .0f * lrs[i]->getRefCount () / (lrs[i]->getDegree () + 1 );
6197
+ spillCost = 1 .0f * lrs[i]->getRefCount () / (lrs[i]->getDegree () + 1 );
6319
6198
}
6320
6199
else
6321
6200
{
6322
6201
assert (lrs[i]->getDcl ()->getTotalElems () > 0 );
6323
- if (!liveAnalysis.livenessClass (G4_GRF))
6324
- {
6325
- // address or flag variables
6326
- unsigned short numRows = lrs[i]->getDcl ()->getNumRows ();
6327
- spillCost = 1 .0f * lrs[i]->getRefCount () * lrs[i]->getRefCount () * lrs[i]->getDcl ()->getByteSize () *
6328
- (float )sqrt (lrs[i]->getDcl ()->getByteSize ())
6329
- / ((float )sqrt (lrs[i]->getDegree () + 1 ) * (float )(sqrt (sqrt (numRows))));
6330
- }
6331
- else
6332
- {
6333
- // GRF variables
6334
-
6335
- auto refCount = getWeightedRefCount (lrs[i]->getDcl ());
6336
- unsigned int degree = 0 ;
6337
- {
6338
- for (unsigned int j = 0 ; j != getIntf ()->getSparseIntfForVar (i).size (); ++j)
6339
- {
6340
- if (lrs[j]->getDcl ()->getByteSize () >= (unsigned int )getGRFSize () / 2 )
6341
- degree += lrs[j]->getDcl ()->getNumRows () + lrs[i]->getDcl ()->getNumRows () - 1 ;
6342
- }
6343
- }
6344
-
6345
- spillCost = 1 .0f * refCount * refCount * refCount
6346
- / ((float )(degree + 1 ) * (float )(degree + 1 ));
6347
- }
6202
+ unsigned short numRows = lrs[i]->getDcl ()->getNumRows ();
6203
+ spillCost = 1 .0f * lrs[i]->getRefCount () * lrs[i]->getRefCount () * lrs[i]->getDcl ()->getByteSize () *
6204
+ (float )sqrt (lrs[i]->getDcl ()->getByteSize ())
6205
+ / ((float )sqrt (lrs[i]->getDegree () + 1 ) * (float )(sqrt (sqrt (numRows))));
6348
6206
}
6349
6207
}
6350
6208
else
6351
6209
{
6352
6210
spillCost =
6353
6211
liveAnalysis.livenessClass (G4_GRF) ?
6354
- lrs[i]->getDegree () : 1 .0f * lrs[i]->getRefCount () * lrs[i]->getRefCount () / (lrs[i]->getDegree () + 1 );
6212
+ lrs[i]->getDegree () : 1 .0f * lrs[i]->getRefCount ()* lrs[i]->getRefCount () / (lrs[i]->getDegree () + 1 );
6355
6213
}
6356
6214
6357
6215
lrs[i]->setSpillCost (spillCost);
@@ -6379,7 +6237,7 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
6379
6237
// normal live ranges, so that they get colored before all the normal
6380
6238
// live ranges.
6381
6239
//
6382
- for (LiveRange* lr : addressSensitiveVars)
6240
+ for (LiveRange * lr : addressSensitiveVars)
6383
6241
{
6384
6242
if (lr->getSpillCost () != MAXSPILLCOST)
6385
6243
{
@@ -6389,7 +6247,6 @@ void GraphColor::computeSpillCosts(bool useSplitLLRHeuristic)
6389
6247
}
6390
6248
6391
6249
6392
-
6393
6250
//
6394
6251
// subtract lr's neighbors that are still in work list
6395
6252
//
0 commit comments