Skip to content

Commit 46ce6ed

Browse files
stefan-iligcbot
authored andcommitted
Refactor getOverlappingIntervals
Minor refactoring as code is quite frequently executed.
1 parent 3356972 commit 46ce6ed

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

visa/SpillManagerGMRF.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ SPDX-License-Identifier: MIT
1414
#include "GraphColor.h"
1515
#include "PointsToAnalysis.h"
1616

17-
#include <fstream>
18-
#include <math.h>
17+
#include <cmath>
1918
#include <sstream>
2019
#include <unordered_set>
2120
#include <optional>
@@ -353,8 +352,8 @@ void SpillManagerGRF::getOverlappingIntervals(
353352
}
354353
}
355354

356-
for (auto &dcl : overlappingDcls)
357-
intervals.push_back(dcl);
355+
intervals.insert(intervals.end(), overlappingDcls.begin(),
356+
overlappingDcls.end());
358357
}
359358

360359
// Calculate the spill memory displacement for the regvar.
@@ -4721,15 +4720,8 @@ unsigned int GlobalRA::GRFSizeToOwords(unsigned int numGRFs,
47214720
unsigned int GlobalRA::getHWordByteSize() { return HWORD_BYTE_SIZE; }
47224721

47234722
bool Interval::intervalsOverlap(const Interval &second) const {
4724-
auto firstStart = start->getLexicalId();
4725-
auto firstEnd = end->getLexicalId();
4726-
auto secondStart = second.start->getLexicalId();
4727-
auto secondEnd = second.end->getLexicalId();
4728-
4729-
if (firstStart > secondEnd || secondStart > firstEnd)
4730-
return false;
4731-
4732-
return true;
4723+
return !(start->getLexicalId() > second.end->getLexicalId() ||
4724+
second.start->getLexicalId() > end->getLexicalId());
47334725
}
47344726

47354727
static G4_INST *createSpillFillAddr(IR_Builder &builder, G4_Declare *addr,

0 commit comments

Comments
 (0)