[llvm] [LV] Optimize VPWidenIntOrFpInductionRecipe for known TC (PR #118828)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 26 13:27:15 PDT 2025
================
@@ -1009,11 +1012,83 @@ void VPlanTransforms::simplifyRecipes(VPlan &Plan, Type &CanonicalIVTy) {
}
}
-void VPlanTransforms::optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF,
- unsigned BestUF,
- PredicatedScalarEvolution &PSE) {
- assert(Plan.hasVF(BestVF) && "BestVF is not available in Plan");
- assert(Plan.hasUF(BestUF) && "BestUF is not available in Plan");
+/// Optimize the width of vector induction variables in \p Plan based on a known
+/// constant Trip Count, \p BestVF and \p BestUF.
+static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
+ ElementCount BestVF,
+ unsigned BestUF) {
+ // Only proceed if we have not completely removed the vector region.
+ if (!Plan.getVectorLoopRegion())
+ return false;
+
+ if (!Plan.getTripCount()->isLiveIn())
+ return false;
+ auto *TC = dyn_cast_if_present<ConstantInt>(
+ Plan.getTripCount()->getUnderlyingValue());
+ if (!TC || !BestVF.isFixed())
+ return false;
+
+ // Calculate the widest type required for known TC, VF and UF.
----------------
fhahn wrote:
```suggestion
// Calculate the minimum power-of-2 bit width that can fit the known TC, VF and UF. Returns at least 8.
```
https://github.com/llvm/llvm-project/pull/118828
More information about the llvm-commits
mailing list