Skip to content

Commit bf9951c

Browse files
committed
Move calculateRegisterUsage out of cost model
1 parent 7881f91 commit bf9951c

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
@@ -1022,12 +1022,6 @@ class LoopVectorizationCostModel {
10221022
SmallMapVector<unsigned, unsigned, 4> MaxLocalUsers;
10231023
};
10241024

1025-
/// \return Returns information about the register usages of the loop for the
1026-
/// given plan and vectorization factors.
1027-
SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
1028-
calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
1029-
const TargetTransformInfo &TTI);
1030-
10311025
/// Collect values we want to ignore in the cost model.
10321026
void collectValuesToIgnore();
10331027

@@ -4867,9 +4861,9 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
48674861

48684862
/// Estimate the register usage for \p Plan and vectorization factors in \p VFs.
48694863
/// Returns the register usage for each VF in \p VFs.
4870-
SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
4871-
LoopVectorizationCostModel::calculateRegisterUsage(
4872-
VPlan &Plan, ArrayRef<ElementCount> VFs, const TargetTransformInfo &TTI) {
4864+
static SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
4865+
calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
4866+
const TargetTransformInfo &TTI) {
48734867
// This function calculates the register usage by measuring the highest number
48744868
// of values that are alive at a single location. Obviously, this is a very
48754869
// rough estimation. We scan the loop in a topological order in order and
@@ -5156,7 +5150,7 @@ LoopVectorizationCostModel::selectInterleaveCount(VPlan &Plan, ElementCount VF,
51565150
return 1;
51575151
}
51585152

5159-
RegisterUsage R = calculateRegisterUsage(Plan, {VF}, TTI)[0];
5153+
RegisterUsage R = ::calculateRegisterUsage(Plan, {VF}, TTI)[0];
51605154
// We divide by these constants so assume that we have at least one
51615155
// instruction that uses at least one register.
51625156
for (auto &Pair : R.MaxLocalUsers) {
@@ -7555,7 +7549,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
75557549

75567550
for (auto &P : VPlans) {
75577551
SmallVector<ElementCount, 1> VFs(P->vectorFactors());
7558-
auto RUs = CM.calculateRegisterUsage(*P, VFs, TTI);
7552+
auto RUs = ::calculateRegisterUsage(*P, VFs, TTI);
75597553
for (unsigned I = 0; I < VFs.size(); I++) {
75607554
auto VF = VFs[I];
75617555
if (VF.isScalar())
@@ -7606,8 +7600,8 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
76067600
SmallVector<ElementCount, 1> VFs = {BestFactor.Width};
76077601

76087602
auto LegacyRUs =
7609-
CM.calculateRegisterUsage(getPlanFor(LegacyVF.Width), LegacyVFs, TTI);
7610-
auto RUs = CM.calculateRegisterUsage(BestPlan, VFs, TTI);
7603+
calculateRegisterUsage(getPlanFor(LegacyVF.Width), LegacyVFs, TTI);
7604+
auto RUs = calculateRegisterUsage(BestPlan, VFs, TTI);
76117605

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

0 commit comments

Comments
 (0)