[llvm] [LV] Ignore some costs when loop gets fully unrolled (PR #106699)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 05:44:42 PST 2024
================
@@ -7223,6 +7251,17 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
continue;
IVInsts.push_back(CI);
}
+
+ // If the vector loop gets executed exactly once with the given VF, ignore
+ // the costs of comparison and induction instructions, as they'll get
+ // simplified away.
+ // TODO: Remove this code after stepping away from the legacy cost model and
+ // adding code to simplify VPlans before calculating their costs.
+ auto TC = PSE.getSE()->getSmallConstantTripCount(OrigLoop);
+ if (VF.isFixed() && TC == VF.getFixedValue())
----------------
david-arm wrote:
I think this should check we're not tail-folding here, i.e.
`if (VF.isFixed() && TC == VF.getFixedValue() && !CM.foldTailByMasking())`
https://github.com/llvm/llvm-project/pull/106699
More information about the llvm-commits
mailing list