Skip to content

Commit 410afea

Browse files
committed
Move calculateRegisterUsage out of cost model
1 parent 67d09bd commit 410afea

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,12 +1048,6 @@ class LoopVectorizationCostModel {
10481048
SmallMapVector<unsigned, unsigned, 4> MaxLocalUsers;
10491049
};
10501050

1051-
/// \return Returns information about the register usages of the loop for the
1052-
/// given plan and vectorization factors.
1053-
SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
1054-
calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
1055-
const TargetTransformInfo &TTI);
1056-
10571051
/// Collect values we want to ignore in the cost model.
10581052
void collectValuesToIgnore();
10591053

@@ -4874,9 +4868,9 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
48744868

48754869
/// Estimate the register usage for \p Plan and vectorization factors in \p VFs.
48764870
/// Returns the register usage for each VF in \p VFs.
4877-
SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
4878-
LoopVectorizationCostModel::calculateRegisterUsage(
4879-
VPlan &Plan, ArrayRef<ElementCount> VFs, const TargetTransformInfo &TTI) {
4871+
static SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
4872+
calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
4873+
const TargetTransformInfo &TTI) {
48804874
// This function calculates the register usage by measuring the highest number
48814875
// of values that are alive at a single location. Obviously, this is a very
48824876
// rough estimation. We scan the loop in a topological order in order and
@@ -5163,7 +5157,7 @@ LoopVectorizationCostModel::selectInterleaveCount(VPlan &Plan, ElementCount VF,
51635157
return 1;
51645158
}
51655159

5166-
RegisterUsage R = calculateRegisterUsage(Plan, {VF}, TTI)[0];
5160+
RegisterUsage R = ::calculateRegisterUsage(Plan, {VF}, TTI)[0];
51675161
// We divide by these constants so assume that we have at least one
51685162
// instruction that uses at least one register.
51695163
for (auto &Pair : R.MaxLocalUsers) {
@@ -7565,7 +7559,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
75657559

75667560
for (auto &P : VPlans) {
75677561
SmallVector<ElementCount, 1> VFs(P->vectorFactors());
7568-
auto RUs = CM.calculateRegisterUsage(*P, VFs, TTI);
7562+
auto RUs = ::calculateRegisterUsage(*P, VFs, TTI);
75697563
for (unsigned I = 0; I < VFs.size(); I++) {
75707564
auto VF = VFs[I];
75717565
if (VF.isScalar())
@@ -7616,8 +7610,8 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
76167610
SmallVector<ElementCount, 1> VFs = {BestFactor.Width};
76177611

76187612
auto LegacyRUs =
7619-
CM.calculateRegisterUsage(getPlanFor(LegacyVF.Width), LegacyVFs, TTI);
7620-
auto RUs = CM.calculateRegisterUsage(BestPlan, VFs, TTI);
7613+
calculateRegisterUsage(getPlanFor(LegacyVF.Width), LegacyVFs, TTI);
7614+
auto RUs = calculateRegisterUsage(BestPlan, VFs, TTI);
76217615

76227616
auto GetMaxUsage = [](SmallMapVector<unsigned, unsigned, 4> MaxLocalUsers) {
76237617
unsigned Max = 0;

0 commit comments

Comments
 (0)