-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[VPlan] Sink vector loop region recipes in licm #172343
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -2465,6 +2465,33 @@ static void licm(VPlan &Plan) { | |
| R.moveBefore(*Preheader, Preheader->end()); | ||
| } | ||
| } | ||
|
|
||
| // Sink any recipes which don't have any users in the region to the nearest | ||
| // common dominator of its users. | ||
| VPDominatorTree VPDT(Plan); | ||
| for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>( | ||
| vp_post_order_shallow(LoopRegion->getEntry()))) { | ||
| for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) { | ||
| if (cannotHoistOrSinkRecipe(R)) | ||
| continue; | ||
| SmallSetVector<VPBasicBlock *, 4> UserVPBBs; | ||
| if (any_of(R.definedValues(), [&UserVPBBs](VPValue *V) { | ||
| return any_of(V->users(), [&UserVPBBs](VPUser *U) { | ||
| auto *UR = cast<VPRecipeBase>(U); | ||
| UserVPBBs.insert(UR->getParent()); | ||
| return UR->getParent()->getEnclosingLoopRegion(); | ||
|
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. Why is a nullptr enclosing loop the right condition for a bail-out?
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. We bail if the recipe is defined in a loop region. This is the equivalent of VPValue::isDefinedOutsideOfLoopRegion in the hoisting code above but operating on recipes. |
||
| }); | ||
| })) | ||
| continue; | ||
| if (UserVPBBs.empty()) | ||
| continue; | ||
| VPBasicBlock *SinkVPBB = UserVPBBs.front(); | ||
| for (auto *UserVPBB : drop_begin(UserVPBBs)) | ||
| SinkVPBB = cast<VPBasicBlock>( | ||
| VPDT.findNearestCommonDominator(SinkVPBB, UserVPBB)); | ||
| R.moveBefore(*SinkVPBB, SinkVPBB->begin()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void VPlanTransforms::truncateToMinimalBitwidths( | ||
|
|
||
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.
Is this a reverse-post-order-shallow walk? Perhaps worth using the RPOT iterator?
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.
We want just regular post order here, RPOT would traverse defs before uses. The block itself is reversed though so we go from bottom to top