[llvm] [LV] Ignore some costs when loop gets fully unrolled (PR #106699)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 05:40:04 PST 2024
================
@@ -7221,6 +7235,20 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
continue;
IVInsts.push_back(CI);
}
+
+ // If with the given VF loop gets fully unrolled, ignore the costs of
+ // comparison and induction instructions, as they'll get simplified away
+ auto TC = CM.PSE.getSE()->getSmallConstantTripCount(OrigLoop);
+ auto *Cmp = OrigLoop->getLatchCmpInst();
+ if (Cmp && TC == VF.getKnownMinValue()) {
+ CostCtx.SkipCostComputation.insert(Cmp);
+ for (const auto &[IV, IndDesc] : Legal->getInductionVars()) {
----------------
david-arm wrote:
Again, same comment as above - there could be outside users of the induction variables and the increment will remain.
https://github.com/llvm/llvm-project/pull/106699
More information about the llvm-commits
mailing list