[llvm] [LV] Ignore some costs when loop gets fully unrolled (PR #106699)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 09:16:38 PST 2024
================
@@ -5557,14 +5576,23 @@ InstructionCost LoopVectorizationCostModel::computePredInstDiscount(
InstructionCost LoopVectorizationCostModel::expectedCost(ElementCount VF) {
InstructionCost Cost;
+ // 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.
+ SmallPtrSet<Instruction *, 2> ValuesToIgnoreForVF;
+ auto TC = PSE.getSE()->getSmallConstantTripCount(TheLoop);
+ if (VF.isFixed() && TC == VF.getFixedValue() && !foldTailByMasking())
----------------
david-arm wrote:
For example, suppose TC=8 and the max VF=16. In this case we *could* choose a VF of 16 and there will be a remainder, but the cost model may prefer VF=8 where there isn't a remainder.
https://github.com/llvm/llvm-project/pull/106699
More information about the llvm-commits
mailing list