[llvm] [LV, VP]VP intrinsics support for the Loop Vectorizer + adding new tail-folding mode using EVL. (PR #76172)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 24 06:40:04 PDT 2024
================
@@ -1505,20 +1508,60 @@ class LoopVectorizationCostModel {
/// Returns the TailFoldingStyle that is best for the current loop.
TailFoldingStyle getTailFoldingStyle(bool IVUpdateMayOverflow = true) const {
- return IVUpdateMayOverflow ? ChosenTailFoldingStyle.first
- : ChosenTailFoldingStyle.second;
+ if (!ChosenTailFoldingStyle.first) {
+ assert(!ChosenTailFoldingStyle.second &&
+ "Chosen tail folding style must not be set.");
+ return TailFoldingStyle::None;
+ }
+ return *(IVUpdateMayOverflow ? ChosenTailFoldingStyle.first
+ : ChosenTailFoldingStyle.second);
}
/// Selects and saves TailFoldingStyle for 2 options - if IV update may
/// overflow or not.
- void setTailFoldingStyles() {
- assert(ChosenTailFoldingStyle.first == TailFoldingStyle::None &&
- ChosenTailFoldingStyle.second == TailFoldingStyle::None &&
+ /// \param IsScalableVF true if scalable vector factors enabled.
+ /// \param UserIC User specific interleave count.
+ void setTailFoldingStyles(bool IsScalableVF, unsigned UserIC) {
+ assert(!ChosenTailFoldingStyle.first && !ChosenTailFoldingStyle.second &&
"Tail folding must not be selected yet.");
if (!Legal->prepareToFoldTailByMasking())
return;
if (ForceTailFoldingStyle.getNumOccurrences()) {
----------------
ayalz wrote:
```suggestion
if (!ForceTailFoldingStyle.getNumOccurrences()) {
ChosenTailFoldingStyle.first =
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true);
ChosenTailFoldingStyle.second =
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false);
return;
}
```
The alternative became longer, easier for this simpler case to go first and early-exit.
https://github.com/llvm/llvm-project/pull/76172
More information about the llvm-commits
mailing list