-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LV]Initial support for safe distance in predicated DataWithEVL vectorization mode. #102897
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 9 commits
fadc2ab
ceed187
afb5bd2
a5c1bc3
5179f0c
ab65708
ee060dc
09b149c
34e7be5
fc73f7d
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 |
|---|---|---|
|
|
@@ -1431,12 +1431,9 @@ class LoopVectorizationCostModel { | |
| // Override forced styles if needed. | ||
| // FIXME: use actual opcode/data type for analysis here. | ||
| // FIXME: Investigate opportunity for fixed vector factor. | ||
| bool EVLIsLegal = | ||
| IsScalableVF && UserIC <= 1 && | ||
| TTI.hasActiveVectorLength(0, nullptr, Align()) && | ||
| !EnableVPlanNativePath && | ||
| // FIXME: implement support for max safe dependency distance. | ||
| Legal->isSafeForAnyVectorWidth(); | ||
| bool EVLIsLegal = UserIC <= 1 && | ||
| TTI.hasActiveVectorLength(0, nullptr, Align()) && | ||
| !EnableVPlanNativePath; | ||
|
Comment on lines
+1434
to
+1436
Collaborator
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. (unrelated to this patch) Should this fallback of EVL, due to UserIC>1 or NativePath, apply to getPreferredTailFoldingStyle() decisions above, in addition to (de)forced styles below? |
||
| if (!EVLIsLegal) { | ||
| // If for some reason EVL mode is unsupported, fallback to | ||
| // DataWithoutLaneMask to try to vectorize the loop with folded tail | ||
|
|
@@ -1461,6 +1458,14 @@ class LoopVectorizationCostModel { | |
| return getTailFoldingStyle() != TailFoldingStyle::None; | ||
| } | ||
|
|
||
| /// Return maximum safe number of elements to be processed, which do not | ||
alexey-bataev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// prevent store-load forwarding and are safe with regard to the memory | ||
| /// dependencies. Required for EVL-based VPlans to correctly calculate AVL | ||
| /// (application vector length) as min(remaining AVL, MaxSafeElements). | ||
| /// TODO: need to consider adjusting cost model to use this value as a | ||
| /// vectorization factor for EVL-based vectorization. | ||
| std::optional<unsigned> getMaxSafeElements() const { return MaxSafeElements; } | ||
|
|
||
| /// Returns true if the instructions in this block requires predication | ||
| /// for any reason, e.g. because tail folding now requires a predicate | ||
| /// or because the block in the original loop was predicated. | ||
|
|
@@ -1612,6 +1617,12 @@ class LoopVectorizationCostModel { | |
| /// true if scalable vectorization is supported and enabled. | ||
| std::optional<bool> IsScalableVectorizationAllowed; | ||
|
|
||
| /// Maximum safe number of elements to be processed per vector iteration, | ||
| /// which do not prevent store-load forwarding and are safe with regard to the | ||
| /// memory dependencies. Required for EVL-based veectorization, where this | ||
| /// value is used as the upper bound of the safe AVL. | ||
| std::optional<unsigned> MaxSafeElements; | ||
|
|
||
| /// A map holding scalar costs for different vectorization factors. The | ||
| /// presence of a cost for an instruction in the mapping indicates that the | ||
| /// instruction will be scalarized when vectorizing with the associated | ||
|
|
@@ -3858,6 +3869,8 @@ FixedScalableVFPair LoopVectorizationCostModel::computeFeasibleMaxVF( | |
|
|
||
| auto MaxSafeFixedVF = ElementCount::getFixed(MaxSafeElements); | ||
| auto MaxSafeScalableVF = getMaxLegalScalableVF(MaxSafeElements); | ||
| if (!Legal->isSafeForAnyVectorWidth()) | ||
| this->MaxSafeElements = MaxSafeElements; | ||
|
|
||
| LLVM_DEBUG(dbgs() << "LV: The max safe fixed VF is: " << MaxSafeFixedVF | ||
| << ".\n"); | ||
|
Collaborator
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. (Also dump max EVL safe VF?) |
||
|
|
@@ -8686,8 +8699,8 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF, | |
| VPlanTransforms::optimize(*Plan); | ||
| // TODO: try to put it close to addActiveLaneMask(). | ||
| // Discard the plan if it is not EVL-compatible | ||
| if (CM.foldTailWithEVL() && | ||
| !VPlanTransforms::tryAddExplicitVectorLength(*Plan)) | ||
| if (CM.foldTailWithEVL() && !VPlanTransforms::tryAddExplicitVectorLength( | ||
| *Plan, CM.getMaxSafeElements())) | ||
| break; | ||
| assert(verifyVPlanIsValid(*Plan) && "VPlan is invalid"); | ||
| VPlans.push_back(std::move(Plan)); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.