Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO-NOT-MERGE: Lsra heuristic reordering #51626

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add getLsraStat() to convert RegisterScore to LsraStat
  • Loading branch information
kunalspathak committed Apr 21, 2021
commit d71024977dd8857da3997607206ce4cf408b1150
56 changes: 53 additions & 3 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8566,6 +8566,57 @@ void LinearScan::updateLsraStat(LsraStat stat, unsigned bbNum)
++(blockInfo[bbNum].stats[(unsigned)stat]);
}


// ----------------------------------------------------------
// getLsraStat: Get lsra stat corresponding to the RegisterScore stat
//
// Arguments:
// heuristic - RegisterScore for which LsraStat is needed
//
LsraStat LinearScan::getLsraStat(RegisterScore heuristic)
{
switch (heuristic)
{
case FREE:
return REGSEL_FREE;
case CONST_AVAILABLE:
return REGSEL_CONST_AVAILABLE;
case THIS_ASSIGNED:
return REGSEL_THIS_ASSIGNED;
case COVERS:
return REGSEL_COVERS;
case OWN_PREFERENCE:
return REGSEL_OWN_PREFERENCE;
case COVERS_RELATED:
return REGSEL_COVERS_RELATED;
case RELATED_PREFERENCE:
return REGSEL_RELATED_PREFERENCE;
case CALLER_CALLEE:
return REGSEL_CALLER_CALLEE;
case UNASSIGNED:
return REGSEL_UNASSIGNED;
case COVERS_FULL:
return REGSEL_COVERS_FULL;
case BEST_FIT:
return REGSEL_BEST_FIT;
case IS_PREV_REG:
return REGSEL_IS_PREV_REG;
case REG_ORDER:
return REGSEL_REG_ORDER;
case SPILL_COST:
return REGSEL_SPILL_COST;
case FAR_NEXT_REF:
return REGSEL_FAR_NEXT_REF;
case PREV_REG_OPT:
return REGSEL_PREV_REG_OPT;
case REG_NUM:
return REGSEL_REG_NUM;
default:
assert(!"Unexpected heuristic");
return REGSEL_FREE;
}
}

// -----------------------------------------------------------
// dumpLsraStats - dumps Lsra stats to given file.
//
Expand Down Expand Up @@ -11102,9 +11153,8 @@ regMaskTP LinearScan::RegisterSelection::select(Interval* currentInterval, RefPo
{
(this->*fn)();
#if TRACK_LSRA_STATS
int heuristic = (int)heuristicToApply;
LsraStat lsraStat = (LsraStat)(4 + heuristicToApply);
INTRACK_STATS_IF(found, linearScan->updateLsraStat(lsraStat, refPosition->bbNum));
INTRACK_STATS_IF(found,
linearScan->updateLsraStat(linearScan->getLsraStat(heuristicToApply), refPosition->bbNum));
#endif // TRACK_LSRA_STATS
}
else
Expand Down
71 changes: 1 addition & 70 deletions src/coreclr/jit/lsra.h
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,7 @@ class LinearScan : public LinearScanInterface
#if TRACK_LSRA_STATS
unsigned regCandidateVarCount;
void updateLsraStat(LsraStat stat, unsigned currentBBNum);
LsraStat getLsraStat(RegisterScore heuristic);
void dumpLsraStats(FILE* file);
LsraStat firstRegSelStat = LsraStat::REGSEL_FREE;

Expand Down Expand Up @@ -2556,76 +2557,6 @@ class RefPosition
};


//
//class RegSel
//{
//public:
// virtual bool applyHeuristics();
//};
//
//template <typename X>
//class RegSelectionHeuristic : RegSel
//{
//public:
// RegSelectionHeuristic(X x)
// {
// action = X;
// }
//
//protected:
// X action;
//};
//
//template <typename X>
//class FreeRegHeurisitic : RegSelectionHeuristic<X>
//{
//public:
// FreeRegHeurisitic(X x)
// : base(x)
// {
//
// }
//
// bool applyHeuristics()
// {
// return action()
// }
//};

//
//class RegSelection
//{
//public:
//
// template <typename X>
// RegSelectionHeuristic<X> append(X heuristic)
// {
// FreeRegHeurisitic free(heuristic);
//
//
// regHeuristics.insert(free);
// }
//
// bool execute()
// {
// for (RegSel* current : *regHeuristics)
// {
// bool found = current->applyHeuristics();
// }
// /*for (int i = 0; i < 10; i++)
// {
// found = regHeuristics[i].applyHeuristics();
// }*/
// return false;
// }
//
//private:
// jitstd::vector<RegSel*>* regHeuristics;
//};




#ifdef DEBUG
void dumpRegMask(regMaskTP regs);
#endif // DEBUG
Expand Down