@@ -15,9 +15,7 @@ SPDX-License-Identifier: MIT
1515#include " PointsToAnalysis.h"
1616
1717#include < cmath>
18- #include < sstream>
1918#include < unordered_set>
20- #include < optional>
2119
2220using namespace vISA ;
2321
@@ -426,14 +424,13 @@ unsigned SpillManagerGRF::calculateSpillDispForLS(G4_RegVar *regVar) const {
426424 // Locate the blocked locations calculated from the interfering
427425 // spilled live ranges and put them into a list in ascending order.
428426
429- typedef std::deque<G4_RegVar *> LocList;
430- LocList locList;
427+ std::vector<G4_RegVar *> locList;
431428 unsigned lrId = (regVar->getId () >= varIdCount_)
432429 ? regVar->getBaseRegVar ()->getId ()
433430 : regVar->getId ();
434431 vASSERT (lrId < varIdCount_);
435432
436- for (auto lr : (*spilledLSLRs_)) {
433+ for (auto * lr : (*spilledLSLRs_)) {
437434 G4_Declare* dcl = regVar->getDeclare ();
438435 while (dcl->getAliasDeclare ()) {
439436 dcl = dcl->getAliasDeclare ();
@@ -452,18 +449,14 @@ unsigned SpillManagerGRF::calculateSpillDispForLS(G4_RegVar *regVar) const {
452449 unsigned iDisp = intfRegVar->getDisp ();
453450 if (iDisp == UINT_MAX)
454451 continue ;
455-
456- LocList::iterator loc;
457- for (loc = locList.begin ();
458- loc != locList.end () && (*loc)->getDisp () < iDisp; ++loc)
459- ;
460- if (loc != locList.end ())
461- locList.insert (loc, intfRegVar);
462- else
463- locList.push_back (intfRegVar);
452+ locList.push_back (intfRegVar);
464453 }
465454 }
466455
456+ std::sort (locList.begin (), locList.end (), [](G4_RegVar *v1, G4_RegVar *v2) {
457+ return v1->getDisp () < v2->getDisp ();
458+ });
459+
467460 // Find a spill slot for lRange within the locList.
468461 // we always start searching from nextSpillOffset_ to facilitate
469462 // intra-iteration reuse. cross iteration reuse is not done in interest of
@@ -472,12 +465,11 @@ unsigned SpillManagerGRF::calculateSpillDispForLS(G4_RegVar *regVar) const {
472465 ROUND (nextSpillOffset_, builder_->numEltPerGRF <Type_UB>());
473466 unsigned regVarSize = getByteSize (regVar);
474467
475- for (LocList::iterator curLoc = locList.begin (), end = locList.end ();
476- curLoc != end; ++curLoc) {
477- unsigned curLocDisp = (*curLoc)->getDisp ();
468+ for (auto * curLoc : locList) {
469+ unsigned curLocDisp = curLoc->getDisp ();
478470 if (regVarLocDisp < curLocDisp && regVarLocDisp + regVarSize <= curLocDisp)
479471 break ;
480- unsigned curLocEnd = curLocDisp + getByteSize (* curLoc);
472+ unsigned curLocEnd = curLocDisp + getByteSize (curLoc);
481473 {
482474 if (curLocEnd % builder_->numEltPerGRF <Type_UB>() != 0 )
483475 curLocEnd = ROUND (curLocEnd, builder_->numEltPerGRF <Type_UB>());
0 commit comments