-
Notifications
You must be signed in to change notification settings - Fork 17.7k
[LV] Remove DataAndControlFlowWithoutRuntimeCheck. NFC #183762
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
Changes from 1 commit
17bb026
a74165d
31f4c5b
960d829
d13671b
778fcea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,9 +243,6 @@ static cl::opt<TailFoldingStyle> ForceTailFoldingStyle( | |
| clEnumValN(TailFoldingStyle::DataAndControlFlow, "data-and-control", | ||
| "Create lane mask using active.lane.mask intrinsic, and use " | ||
| "it for both data and control flow"), | ||
| clEnumValN(TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck, | ||
| "data-and-control-without-rt-check", | ||
| "Similar to data-and-control, but remove the runtime check"), | ||
| clEnumValN(TailFoldingStyle::DataWithEVL, "data-with-evl", | ||
| "Use predicated EVL instructions for tail folding. If EVL " | ||
| "is unsupported, fallback to data-without-lane-mask."))); | ||
|
|
@@ -1327,11 +1324,10 @@ class LoopVectorizationCostModel { | |
| } | ||
|
|
||
| /// Returns the TailFoldingStyle that is best for the current loop. | ||
| TailFoldingStyle getTailFoldingStyle(bool IVUpdateMayOverflow = true) const { | ||
| TailFoldingStyle getTailFoldingStyle() const { | ||
| if (!ChosenTailFoldingStyle) | ||
| return TailFoldingStyle::None; | ||
| return IVUpdateMayOverflow ? ChosenTailFoldingStyle->first | ||
| : ChosenTailFoldingStyle->second; | ||
| return *ChosenTailFoldingStyle; | ||
| } | ||
|
|
||
| /// Selects and saves TailFoldingStyle for 2 options - if IV update may | ||
|
|
@@ -1341,20 +1337,16 @@ class LoopVectorizationCostModel { | |
| void setTailFoldingStyles(bool IsScalableVF, unsigned UserIC) { | ||
| assert(!ChosenTailFoldingStyle && "Tail folding must not be selected yet."); | ||
| if (!Legal->canFoldTailByMasking()) { | ||
| ChosenTailFoldingStyle = {TailFoldingStyle::None, TailFoldingStyle::None}; | ||
| ChosenTailFoldingStyle = TailFoldingStyle::None; | ||
| return; | ||
| } | ||
|
|
||
| // Default to TTI preference, but allow command line override. | ||
| ChosenTailFoldingStyle = { | ||
| TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/true), | ||
| TTI.getPreferredTailFoldingStyle(/*IVUpdateMayOverflow=*/false)}; | ||
| ChosenTailFoldingStyle = TTI.getPreferredTailFoldingStyle(); | ||
| if (ForceTailFoldingStyle.getNumOccurrences()) | ||
| ChosenTailFoldingStyle = {ForceTailFoldingStyle.getValue(), | ||
| ForceTailFoldingStyle.getValue()}; | ||
| ChosenTailFoldingStyle = ForceTailFoldingStyle.getValue(); | ||
|
|
||
| if (ChosenTailFoldingStyle->first != TailFoldingStyle::DataWithEVL && | ||
| ChosenTailFoldingStyle->second != TailFoldingStyle::DataWithEVL) | ||
| if (ChosenTailFoldingStyle != TailFoldingStyle::DataWithEVL) | ||
| return; | ||
| // Override EVL styles if needed. | ||
| // FIXME: Investigate opportunity for fixed vector factor. | ||
|
|
@@ -1366,10 +1358,9 @@ class LoopVectorizationCostModel { | |
| // if it's allowed, or DataWithoutLaneMask otherwise. | ||
| if (ScalarEpilogueStatus == CM_ScalarEpilogueAllowed || | ||
| ScalarEpilogueStatus == CM_ScalarEpilogueNotNeededUsePredicate) | ||
| ChosenTailFoldingStyle = {TailFoldingStyle::None, TailFoldingStyle::None}; | ||
| ChosenTailFoldingStyle = TailFoldingStyle::None; | ||
| else | ||
| ChosenTailFoldingStyle = {TailFoldingStyle::DataWithoutLaneMask, | ||
| TailFoldingStyle::DataWithoutLaneMask}; | ||
| ChosenTailFoldingStyle = TailFoldingStyle::DataWithoutLaneMask; | ||
|
|
||
| LLVM_DEBUG( | ||
| dbgs() << "LV: Preference for VP intrinsics indicated. Will " | ||
|
|
@@ -1381,8 +1372,6 @@ class LoopVectorizationCostModel { | |
|
|
||
| /// Returns true if all loop blocks should be masked to fold tail loop. | ||
| bool foldTailByMasking() const { | ||
| // TODO: check if it is possible to check for None style independent of | ||
| // IVUpdateMayOverflow flag in getTailFoldingStyle. | ||
| return getTailFoldingStyle() != TailFoldingStyle::None; | ||
| } | ||
|
|
||
|
|
@@ -1393,8 +1382,7 @@ class LoopVectorizationCostModel { | |
| return false; | ||
|
|
||
| TailFoldingStyle TF = getTailFoldingStyle(); | ||
| return TF == TailFoldingStyle::DataAndControlFlow || | ||
| TF == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck; | ||
| return TF == TailFoldingStyle::DataAndControlFlow; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think you can just do
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, done in 31f4c5b |
||
| } | ||
|
|
||
| /// Return maximum safe number of elements to be processed per vector | ||
|
|
@@ -1608,8 +1596,7 @@ class LoopVectorizationCostModel { | |
|
|
||
| /// Control finally chosen tail folding style. The first element is used if | ||
| /// the IV update may overflow, the second element - if it does not. | ||
| std::optional<std::pair<TailFoldingStyle, TailFoldingStyle>> | ||
| ChosenTailFoldingStyle; | ||
| std::optional<TailFoldingStyle> ChosenTailFoldingStyle; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as above - does this still need to be an optional?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setTailFoldingStyle checks it's unset to make sure it's only set once, but looking through the git blame it looks like it didn't used to be an std::optional before the EVL stuff was added, it just checked it was TailFoldingStyle::None. Removed the optional in d13671b, good idea thanks! The type's much simpler now |
||
|
|
||
| /// true if scalable vectorization is supported and enabled. | ||
| std::optional<bool> IsScalableVectorizationAllowed; | ||
|
|
@@ -2098,13 +2085,11 @@ class GeneratedRTChecks { | |
|
|
||
| static bool useActiveLaneMask(TailFoldingStyle Style) { | ||
| return Style == TailFoldingStyle::Data || | ||
| Style == TailFoldingStyle::DataAndControlFlow || | ||
| Style == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck; | ||
| Style == TailFoldingStyle::DataAndControlFlow; | ||
| } | ||
|
|
||
| static bool useActiveLaneMaskForControlFlow(TailFoldingStyle Style) { | ||
| return Style == TailFoldingStyle::DataAndControlFlow || | ||
| Style == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck; | ||
| return Style == TailFoldingStyle::DataAndControlFlow; | ||
| } | ||
|
|
||
| // Return true if \p OuterLp is an outer loop annotated with hints for explicit | ||
|
|
@@ -8194,7 +8179,7 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes( | |
| for (ElementCount VF : Range) | ||
| IVUpdateMayOverflow |= !isIndvarOverflowCheckKnownFalse(&CM, VF); | ||
|
|
||
| TailFoldingStyle Style = CM.getTailFoldingStyle(IVUpdateMayOverflow); | ||
| TailFoldingStyle Style = CM.getTailFoldingStyle(); | ||
| // Use NUW for the induction increment if we proved that it won't overflow in | ||
| // the vector loop or when not folding the tail. In the later case, we know | ||
| // that the canonical induction increment will not overflow as the vector trip | ||
|
|
@@ -8406,10 +8391,7 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes( | |
| // TODO: Move checks to VPlanTransforms::addActiveLaneMask once | ||
| // TailFoldingStyle is visible there. | ||
| bool ForControlFlow = useActiveLaneMaskForControlFlow(Style); | ||
| bool WithoutRuntimeCheck = | ||
| Style == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck; | ||
| VPlanTransforms::addActiveLaneMask(*Plan, ForControlFlow, | ||
| WithoutRuntimeCheck); | ||
| VPlanTransforms::addActiveLaneMask(*Plan, ForControlFlow); | ||
| } | ||
| VPlanTransforms::optimizeInductionExitUsers(*Plan, IVEndValues, PSE); | ||
|
|
||
|
|
||
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.
nit: Can this just be a one-liner, i.e.
In fact, do we still need
ChosenTailFoldingStyleto be optional?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.
Thanks, done in 31f4c5b