[llvm] [LV] Add -fold-epilogue-tail option for tail-folded epilogue (PR #190697)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 2 14:02:37 PDT 2026
================
@@ -198,12 +198,17 @@ static cl::opt<unsigned> VectorizeMemoryCheckThreshold(
"vectorize-memory-check-threshold", cl::init(128), cl::Hidden,
cl::desc("The maximum allowed number of runtime memory checks"));
-/// Option tail-folding-policy indicates that an epilogue is undesired, that
-/// tail folding is preferred, and this lists all options. I.e., the vectorizer
-/// will try to fold the tail-loop (epilogue) into the vector body and predicate
-/// the instructions accordingly. If tail-folding fails, there are different
-/// fallback strategies depending on these values:
-enum class TailFoldingPolicyTy { None = 0, PreferFoldTail, MustFoldTail };
+/// Option tail-folding-policy controls the tail-folding strategy and lists all
+/// available options. The vectorizer will attempt to fold the tail-loop into
+/// the vector loop (main/epilogue loops) and predicate the instructions
+/// accordingly. If tail-folding fails, there are different fallback strategies
+/// depending on these values:
+enum class TailFoldingPolicyTy {
----------------
ayalz wrote:
Conceptually, there could be a policy for the main loop (as now) plus another policy for the epilog loop. However, if the main loop `MustFoldTail` then no policy is relevant for the epilog - because it will not exist. Also, if the main loop `PrefersFoldTail` - but fails and an epilog does exist, it too would probably not be able to fold its tail. So a policy for epilog is relevant only if the main loop "must-not-fold-tail". Therefore it's reasonable to fuse both policies into one.
Should a `MustFoldTail` option also apply to the epilog loop, i.e., `MustFoldEpilogTail`, in addition to its `PreferFoldEpilogTail` option, or does "must" aim to retain a single (main) loop, to limit code size.
Does `None` mean "must-not-fold-tail" as in "no-folding", as opposed to "no-policy-specified"? Will `None` now mean both main and epilog must not fold their tail, while `PreferFoldEpilogTail` implies main loop (only) must not fold its tail.
https://github.com/llvm/llvm-project/pull/190697
More information about the llvm-commits
mailing list