[llvm] b4efc0f - [LV] Break up condition in selectEpilogueVectorizationFactor loop (NFCI)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 3 14:39:53 PDT 2023
Author: Florian Hahn
Date: 2023-07-03T22:39:40+01:00
New Revision: b4efc0f070baefa6a308f0cf4d23cd71ad608deb
URL: https://github.com/llvm/llvm-project/commit/b4efc0f070baefa6a308f0cf4d23cd71ad608deb
DIFF: https://github.com/llvm/llvm-project/commit/b4efc0f070baefa6a308f0cf4d23cd71ad608deb.diff
LOG: [LV] Break up condition in selectEpilogueVectorizationFactor loop (NFCI)
Restructure the loop as suggested in D154264 to increase readability and
make it easier to extend.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index bf0ce24c318ea0..b60c538c535327 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5699,13 +5699,21 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
EstimatedRuntimeVF *= *VScale;
}
- for (auto &NextVF : ProfitableVFs)
- if (((!NextVF.Width.isScalable() && MainLoopVF.isScalable() &&
- ElementCount::isKnownLT(NextVF.Width, EstimatedRuntimeVF)) ||
- ElementCount::isKnownLT(NextVF.Width, MainLoopVF)) &&
- (Result.Width.isScalar() || isMoreProfitable(NextVF, Result)) &&
- hasPlanWithVF(NextVF.Width))
+ for (auto &NextVF : ProfitableVFs) {
+ // Skip candidate VFs without a corresponding VPlan.
+ if (!hasPlanWithVF(NextVF.Width))
+ continue;
+
+ // Skip candidate VFs with widths >= the estimate runtime VF (scalable
+ // vectors) or the VF of the main loop (fixed vectors).
+ if ((!NextVF.Width.isScalable() && MainLoopVF.isScalable() &&
+ ElementCount::isKnownGE(NextVF.Width, EstimatedRuntimeVF)) ||
+ ElementCount::isKnownGE(NextVF.Width, MainLoopVF))
+ continue;
+
+ if (Result.Width.isScalar() || isMoreProfitable(NextVF, Result))
Result = NextVF;
+ }
if (Result != VectorizationFactor::Disabled())
LLVM_DEBUG(dbgs() << "LEV: Vectorizing epilogue loop with VF = "
More information about the llvm-commits
mailing list