Skip to content

Commit 9a6d28c

Browse files
committed
Move calculateRegisterUsage out of cost model
1 parent 9ef8f20 commit 9a6d28c

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

@@ -4870,9 +4864,9 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
48704864

48714865
/// Estimate the register usage for \p Plan and vectorization factors in \p VFs.
48724866
/// Returns the register usage for each VF in \p VFs.
4873-
SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
4874-
LoopVectorizationCostModel::calculateRegisterUsage(
4875-
VPlan &Plan, ArrayRef<ElementCount> VFs, const TargetTransformInfo &TTI) {
4867+
static SmallVector<LoopVectorizationCostModel::RegisterUsage, 8>
4868+
calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
4869+
const TargetTransformInfo &TTI) {
48764870
// This function calculates the register usage by measuring the highest number
48774871
// of values that are alive at a single location. Obviously, this is a very
48784872
// rough estimation. We scan the loop in a topological order in order and
@@ -5159,7 +5153,7 @@ LoopVectorizationCostModel::selectInterleaveCount(VPlan &Plan, ElementCount VF,
51595153
return 1;
51605154
}
51615155

5162-
RegisterUsage R = calculateRegisterUsage(Plan, {VF}, TTI)[0];
5156+
RegisterUsage R = ::calculateRegisterUsage(Plan, {VF}, TTI)[0];
51635157
// We divide by these constants so assume that we have at least one
51645158
// instruction that uses at least one register.
51655159
for (auto &Pair : R.MaxLocalUsers) {
@@ -7558,7 +7552,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
75587552

75597553
for (auto &P : VPlans) {
75607554
SmallVector<ElementCount, 1> VFs(P->vectorFactors());
7561-
auto RUs = CM.calculateRegisterUsage(*P, VFs, TTI);
7555+
auto RUs = ::calculateRegisterUsage(*P, VFs, TTI);
75627556
for (unsigned I = 0; I < VFs.size(); I++) {
75637557
auto VF = VFs[I];
75647558
if (VF.isScalar())
@@ -7609,8 +7603,8 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
76097603
SmallVector<ElementCount, 1> VFs = {BestFactor.Width};
76107604

76117605
auto LegacyRUs =
7612-
CM.calculateRegisterUsage(getPlanFor(LegacyVF.Width), LegacyVFs, TTI);
7613-
auto RUs = CM.calculateRegisterUsage(BestPlan, VFs, TTI);
7606+
calculateRegisterUsage(getPlanFor(LegacyVF.Width), LegacyVFs, TTI);
7607+
auto RUs = calculateRegisterUsage(BestPlan, VFs, TTI);
76147608

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

0 commit comments

Comments
 (0)