[llvm] [LV] Consider EVL legality for TTI tail folding preference (PR #144790)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 18 13:26:49 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Philip Reames (preames)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/144790.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+20-23)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 2f4416d2782e8..fdcc61a5205ce 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1364,16 +1364,14 @@ class LoopVectorizationCostModel {
return;
}
- if (!ForceTailFoldingStyle.getNumOccurrences()) {
- ChosenTailFoldingStyle = {
- TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
- TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
- return;
- }
+ // Default to TTI preference, but allow command line override.
+ ChosenTailFoldingStyle = {
+ TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true),
+ TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)};
+ if (ForceTailFoldingStyle.getNumOccurrences())
+ ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
+ ForceTailFoldingStyle.getValue()};
- // Set styles when forced.
- ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(),
- ForceTailFoldingStyle.getValue()};
if (ForceTailFoldingStyle != TailFoldingStyle::DataWithEVL)
return;
// Override forced styles if needed.
@@ -1382,20 +1380,19 @@ class LoopVectorizationCostModel {
bool EVLIsLegal = UserIC <= 1 && IsScalableVF &&
TTI.hasActiveVectorLength(0, nullptr, Align()) &&
!EnableVPlanNativePath;
- if (!EVLIsLegal) {
- // If for some reason EVL mode is unsupported, fallback to
- // DataWithoutLaneMask to try to vectorize the loop with folded tail
- // in a generic way.
- ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
- TailFoldingStyle::DataWithoutLaneMask};
- LLVM_DEBUG(
- dbgs()
- << "LV: Preference for VP intrinsics indicated. Will "
- "not try to generate VP Intrinsics "
- << (UserIC > 1
- ? "since interleave count specified is greater than 1.\n"
- : "due to non-interleaving reasons.\n"));
- }
+ if (EVLIsLegal)
+ return;
+ // If for some reason EVL mode is unsupported, fallback to
+ // DataWithoutLaneMask to try to vectorize the loop with folded tail
+ // in a generic way.
+ ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask,
+ TailFoldingStyle::DataWithoutLaneMask};
+ LLVM_DEBUG(
+ dbgs() << "LV: Preference for VP intrinsics indicated. Will "
+ "not try to generate VP Intrinsics "
+ << (UserIC > 1
+ ? "since interleave count specified is greater than 1.\n"
+ : "due to non-interleaving reasons.\n"));
}
/// Returns true if all loop blocks should be masked to fold tail loop.
``````````
</details>
https://github.com/llvm/llvm-project/pull/144790
More information about the llvm-commits
mailing list