-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LV] Limits the splat operations be hoisted must not be defined by a recipe. #117138
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 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 |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include "VPlan.h" | ||
#include "LoopVectorizationPlanner.h" | ||
#include "VPlanCFG.h" | ||
#include "VPlanDominatorTree.h" | ||
#include "VPlanHelpers.h" | ||
#include "VPlanPatternMatch.h" | ||
#include "VPlanTransforms.h" | ||
|
@@ -221,7 +222,7 @@ VPTransformState::VPTransformState(const TargetTransformInfo *TTI, | |
Loop *CurrentParentLoop, Type *CanonicalIVTy) | ||
: TTI(TTI), VF(VF), CFG(DT), LI(LI), Builder(Builder), ILV(ILV), Plan(Plan), | ||
CurrentParentLoop(CurrentParentLoop), LVer(nullptr), | ||
TypeAnalysis(CanonicalIVTy) {} | ||
TypeAnalysis(CanonicalIVTy), VPDT(*Plan) {} | ||
|
||
Value *VPTransformState::get(const VPValue *Def, const VPLane &Lane) { | ||
if (Def->isLiveIn()) | ||
|
@@ -264,7 +265,11 @@ Value *VPTransformState::get(const VPValue *Def, bool NeedsScalar) { | |
return Data.VPV2Vector[Def]; | ||
|
||
auto GetBroadcastInstrs = [this, Def](Value *V) { | ||
bool SafeToHoist = Def->isDefinedOutsideLoopRegions(); | ||
bool SafeToHoist = | ||
!Def->hasDefiningRecipe() || | ||
VPDT.properlyDominates(Def->getDefiningRecipe()->getParent(), | ||
Plan->getVectorPreheader()); | ||
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. IICU properlyDominates means that we won't consider things as safe-to-hoist if they are defined int he vector preheader, but that would also be safe, as we insert at the end of the vector preheader. Can we catch this also by checking if it properly dominates the vector loop region? 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. Maybe we could use However, I don’t understand the benefit of doing so. In my opinion, if I might be missing something—could you please explain the advantages of this change in more detail? 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. Ping @fhahn 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 could have users in the entry block as well, but here we only ever hoist to the vector preheader, so that should be fine as-is for now, thanks |
||
|
||
if (VF.isScalar()) | ||
return V; | ||
// Place the code for broadcasting invariant variables in the new preheader. | ||
|
@@ -929,6 +934,10 @@ void VPlan::execute(VPTransformState *State) { | |
State->CFG.PrevVPBB = nullptr; | ||
State->CFG.ExitBB = State->CFG.PrevBB->getSingleSuccessor(); | ||
|
||
// Update VPDominatorTree since VPBasicBlock may be removed after State was | ||
// constructed. | ||
State->VPDT.recalculate(*this); | ||
|
||
// Disconnect VectorPreHeader from ExitBB in both the CFG and DT. | ||
BasicBlock *VectorPreHeader = State->CFG.PrevBB; | ||
cast<BranchInst>(VectorPreHeader->getTerminator())->setSuccessor(0, nullptr); | ||
|
Uh oh!
There was an error while loading. Please reload this page.