[llvm] d8e6d74 - [LV] Consider EVL legality for TTI tail folding preference (#144790)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 19 16:15:26 PDT 2025
Author: Philip Reames
Date: 2025-06-19T16:15:23-07:00
New Revision: d8e6d74c6905b3032a3dc9b686bd80bb3feb9857
URL: https://github.com/llvm/llvm-project/commit/d8e6d74c6905b3032a3dc9b686bd80bb3feb9857
DIFF: https://github.com/llvm/llvm-project/commit/d8e6d74c6905b3032a3dc9b686bd80bb3feb9857.diff
LOG: [LV] Consider EVL legality for TTI tail folding preference (#144790)
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9a2cd94eda58f..d9f53c4146c28 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1364,36 +1364,33 @@ 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.
// FIXME: Investigate opportunity for fixed vector factor.
bool EVLIsLegal = UserIC <= 1 && IsScalableVF &&
TTI.hasActiveVectorLength() && !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.
More information about the llvm-commits
mailing list