[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:00 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;
----------------
ayalz wrote:

```suggestion
    if (!Legal->prepareToFoldTailByMasking()) {
      ChosenTailFoldingStyle.first = ChosenTailFoldingStyle.second = None;
      return;
    }
```

https://github.com/llvm/llvm-project/pull/76172


More information about the llvm-commits mailing list