-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[LV] Consider EVL legality for TTI tail folding preference #144790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-transforms Author: Philip Reames (preames) ChangesFull diff: https://github.com/llvm/llvm-project/pull/144790.diff 1 Files Affected:
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.
|
ChosenTailFoldingStyle = { | ||
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true), | ||
TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a test for this change, I assume
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way to test this with in tree backends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/141/builds/9572 Here is the relevant piece of the build log for the reference
|
No description provided.