[llvm] [LV] Add -fold-epilogue-tail option for tail-folded epilogue (PR #190697)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 03:32:01 PDT 2026
================
@@ -804,6 +812,12 @@ enum EpilogueLowering {
// Loop hint indicating an epilogue is undesired, apply tail folding.
CM_EpilogueNotNeededFoldTail,
+ // Tail-folded vector epilogue requested; the scalar tail will be folded into
+ // the vectorized epilogue loop if possible, otherwise fall back to an
+ // epilogue. This status is specifically for the CM instance of the
+ // tail-folded epilogue.
+ CM_EpilogueNotNeededFoldEpilogueTail,
----------------
david-arm wrote:
I can't see anything in this PR that uses or sets this new enum so it's not being tested. I think it might be good to either:
1. Remove the enum, or
2. Add code that tests the enum. Places where the enum is set or used - `isEpilogueAllowed`, `preferTailFoldedLoop`, `setTailFoldingStyle`, `computeMaxVF`, `getEpilogueLowering`, `processLoop`.
For example, in this PR we will still call `getEpilogueLowering` before hitting the report `fold-epilogue-tail is not supported`. In `getEpilogueLowering ` you could return this new enum. Then on line 8388 (processLoop) there is code that checks the enum for low trip counts:
```
if (SEL != CM_EpilogueNotNeededFoldTail)
SEL = CM_EpilogueNotAllowedLowTripLoop;
```
In this case without any modifications your new status will get overridden with `CM_EpilogueNotAllowedLowTripLoop` so we won't generate an epilogue. You could use this to write a test for a loop with a low trip count (e.g. 10) while using the new `-tail-folding-policy=fold-epilogue-tail` option. That way we will at least have one test for the new enum? Then on line 8450 instead of testing the new command line option directly you could do:
```
if (SEL == CM_EpilogueNotNeededFoldEpilogueTail) {
// TODO: Apply tail-folding on the vectorized epilogue loop.
LLVM_DEBUG(dbgs() << "LV: epilogue tail-folding is not supported yet\n");
reportVectorizationInfo("The tail-folding policy fold-epilogue-tail is not "
"supported yet, fall back to an epilogue",
"UnsupportedTailFoldingPolicy", ORE, L);
}
```
https://github.com/llvm/llvm-project/pull/190697
More information about the llvm-commits
mailing list