Skip to content

Commit ee9aa15

Browse files
committed
Add useMaxBandwidth for VF
1 parent 8de22c0 commit ee9aa15

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -957,9 +957,13 @@ class LoopVectorizationCostModel {
957957
}
958958

959959
/// \return True if maximizing vector bandwidth is enabled by the target or
960-
/// user options.
960+
/// user options, for the given register kind.
961961
bool useMaxBandwidth(TargetTransformInfo::RegisterKind RegKind);
962962

963+
/// \return True if maximizing vector bandwidth is enabled by the target or
964+
/// user options, for the given vector factor.
965+
bool useMaxBandwidth(ElementCount VF);
966+
963967
/// \return The size (in bits) of the smallest and widest types in the code
964968
/// that needs to be vectorized. We ignore values that remain scalar such as
965969
/// 64 bit loop indices.
@@ -3922,6 +3926,12 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
39223926
return FixedScalableVFPair::getNone();
39233927
}
39243928

3929+
bool LoopVectorizationCostModel::useMaxBandwidth(ElementCount VF) {
3930+
return useMaxBandwidth(VF.isScalable()
3931+
? TargetTransformInfo::RGK_ScalableVector
3932+
: TargetTransformInfo::RGK_FixedWidthVector);
3933+
}
3934+
39253935
bool LoopVectorizationCostModel::useMaxBandwidth(
39263936
TargetTransformInfo::RegisterKind RegKind) {
39273937
return MaximizeBandwidth || (MaximizeBandwidth.getNumOccurrences() == 0 &&
@@ -4364,10 +4374,7 @@ VectorizationFactor LoopVectorizationPlanner::selectVectorizationFactor() {
43644374

43654375
/// Don't consider the VF if it exceeds the number of registers for the
43664376
/// target.
4367-
if (CM.useMaxBandwidth(VF.isScalable()
4368-
? TargetTransformInfo::RGK_ScalableVector
4369-
: TargetTransformInfo::RGK_FixedWidthVector) &&
4370-
RUs[I].exceedsMaxNumRegs(TTI))
4377+
if (CM.useMaxBandwidth(VF) && RUs[I].exceedsMaxNumRegs(TTI))
43714378
continue;
43724379

43734380
InstructionCost C = CM.expectedCost(VF);
@@ -7143,10 +7150,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
71437150
InstructionCost Cost = cost(*P, VF);
71447151
VectorizationFactor CurrentFactor(VF, Cost, ScalarCost);
71457152

7146-
if (CM.useMaxBandwidth(VF.isScalable()
7147-
? TargetTransformInfo::RGK_ScalableVector
7148-
: TargetTransformInfo::RGK_FixedWidthVector) &&
7149-
RUs[I].exceedsMaxNumRegs(TTI)) {
7153+
if (CM.useMaxBandwidth(VF) && RUs[I].exceedsMaxNumRegs(TTI)) {
71507154
LLVM_DEBUG(dbgs() << "LV(REG): Not considering vector loop of width "
71517155
<< VF << " because it uses too many registers\n");
71527156
continue;

0 commit comments

Comments
 (0)