[llvm] [LV] Support tail-folded epilogue loops (PR #208764)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 06:56:43 PDT 2026
================
@@ -3034,6 +3034,9 @@ LoopVectorizationCostModel::computeMaxVF(ElementCount UserVF, unsigned UserIC) {
MaxPowerOf2RuntimeVF = std::nullopt; // Stick with tail-folding for now.
}
+ // TODO: Make NoScalarEpilogueNeeded lambda a separate function to be used
+ // only for main loop VF not also epilogueVF. Using it for epilogueVF against
+ // full TC is inaccurate.
----------------
david-arm wrote:
OK I see. However, there are definitely cases where `NoScalarEpilogueNeeded` would return a different answer depending upon whether it's for the main loop or epilogue. Examples:
== Example 1 ==
Forced Main Loop VF = 16
Interleave Count = 1
Forced Epilogue Loop VF = 8
Trip Count = 24
Main Loop: URem(24, 16 * 1) != 0
Epilogue Loop: URem(24, 8 * 1) == 0
== Example 2 ==
Forced Main Loop VF = 8
Forced Interleave Count = 3
Forced Epilogue Loop VF = 8
Trip Count = 24
Main Loop: URem(24, 8 * 3) != 0
Epilogue Loop: URem(24, 8 * 1) == 0
In both examples we will say that no epilogue is needed (because we're using the epilogue VF to determine the answer), which isn't true. It's not really a bug because the worst case here is we miss out on performance opportunities by not using tail-folded epilogues. You have covered this with the TODO comment above though, which can be fixed in a follow-on PR.
https://github.com/llvm/llvm-project/pull/208764
More information about the llvm-commits
mailing list