[llvm] [LV] Fix MVE regression from #132190 (PR #141736)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 9 07:55:43 PDT 2025
================
@@ -4349,15 +4358,24 @@ VectorizationFactor LoopVectorizationPlanner::selectVectorizationFactor() {
for (auto &P : VPlans) {
ArrayRef<ElementCount> VFs(P->vectorFactors().begin(),
P->vectorFactors().end());
- auto RUs = calculateRegisterUsageForPlan(*P, VFs, TTI, CM.ValuesToIgnore);
- for (auto [VF, RU] : zip_equal(VFs, RUs)) {
+
+ SmallVector<VPRegisterUsage, 8> RUs;
+ if (CM.useMaxBandwidth(TargetTransformInfo::RGK_ScalableVector) ||
+ CM.useMaxBandwidth(TargetTransformInfo::RGK_FixedWidthVector))
+ RUs = calculateRegisterUsageForPlan(*P, VFs, TTI, CM.ValuesToIgnore);
+
+ for (unsigned I = 0; I < VFs.size(); I++) {
+ ElementCount VF = VFs[I];
// The cost for scalar VF=1 is already calculated, so ignore it.
if (VF.isScalar())
continue;
/// Don't consider the VF if it exceeds the number of registers for the
/// target.
- if (RU.exceedsMaxNumRegs(TTI))
+ if (CM.useMaxBandwidth(VF.isScalable()
----------------
david-arm wrote:
nit: This is just a suggestion, but you could add an overloaded version of CM.useMaxBandwidth that takes an ElementCount and does something like:
```
bool useMaxBandwidth(ElementCount VF) {
return useMaxBandwidth(VF.isScalable() ? ...);
}
```
and use that here and in `computeBestVF`?
https://github.com/llvm/llvm-project/pull/141736
More information about the llvm-commits
mailing list