-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
[VPlan] Move recording of Inst->VPValue to VPRecipeBuilder (NFCI). #84464
Changes from all commits
b09a411
c8d3d33
c509520
68add0e
ae8e890
44bd0c7
bd52701
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 |
---|---|---|
|
@@ -52,9 +52,8 @@ class VPRecipeBuilder { | |
EdgeMaskCacheTy EdgeMaskCache; | ||
BlockMaskCacheTy BlockMaskCache; | ||
|
||
// VPlan-VPlan transformations support: Hold a mapping from ingredients to | ||
// their recipe. To save on memory, only do so for selected ingredients, | ||
// marked by having a nullptr entry in this map. | ||
// VPlan construction support: Hold a mapping from ingredients to | ||
// their recipe. | ||
DenseMap<Instruction *, VPRecipeBase *> Ingredient2Recipe; | ||
|
||
/// Cross-iteration reduction & first-order recurrence phis for which we need | ||
|
@@ -117,13 +116,10 @@ class VPRecipeBuilder { | |
ArrayRef<VPValue *> Operands, | ||
VFRange &Range, VPBasicBlock *VPBB); | ||
|
||
/// Set the recipe created for given ingredient. This operation is a no-op for | ||
/// ingredients that were not marked using a nullptr entry in the map. | ||
/// Set the recipe created for given ingredient. | ||
void setRecipe(Instruction *I, VPRecipeBase *R) { | ||
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. Worth asserting to avoid resetting an already set recipe? 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. Added assert, thanks! |
||
if (!Ingredient2Recipe.count(I)) | ||
return; | ||
assert(Ingredient2Recipe[I] == nullptr && | ||
"Recipe already set for ingredient"); | ||
assert(!Ingredient2Recipe.contains(I) && | ||
"Cannot reset recipe for instruction."); | ||
Ingredient2Recipe[I] = R; | ||
} | ||
|
||
|
@@ -146,14 +142,6 @@ class VPRecipeBuilder { | |
/// between SRC and DST. | ||
VPValue *getEdgeMask(BasicBlock *Src, BasicBlock *Dst) const; | ||
|
||
/// Mark given ingredient for recording its recipe once one is created for | ||
/// it. | ||
void recordRecipeOf(Instruction *I) { | ||
assert((!Ingredient2Recipe.count(I) || Ingredient2Recipe[I] == nullptr) && | ||
"Recipe already set for ingredient"); | ||
Ingredient2Recipe[I] = nullptr; | ||
} | ||
|
||
/// Return the recipe created for given ingredient. | ||
VPRecipeBase *getRecipe(Instruction *I) { | ||
assert(Ingredient2Recipe.count(I) && | ||
|
@@ -171,6 +159,19 @@ class VPRecipeBuilder { | |
/// Add the incoming values from the backedge to reduction & first-order | ||
/// recurrence cross-iteration phis. | ||
void fixHeaderPhis(); | ||
|
||
/// Returns a range mapping the values of the range \p Operands to their | ||
/// corresponding VPValues. | ||
iterator_range<mapped_iterator<Use *, std::function<VPValue *(Value *)>>> | ||
mapToVPValues(User::op_range Operands); | ||
|
||
VPValue *getVPValueOrAddLiveIn(Value *V, VPlan &Plan) { | ||
if (auto *I = dyn_cast<Instruction>(V)) { | ||
if (auto *R = Ingredient2Recipe.lookup(I)) | ||
return R->getVPSingleValue(); | ||
} | ||
return Plan.getVPValueOrAddLiveIn(V); | ||
} | ||
}; | ||
} // end namespace llvm | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,15 +48,14 @@ void VPlanTransforms::VPInstructionsToVPRecipes( | |
VPRecipeBase *NewRecipe = nullptr; | ||
if (auto *VPPhi = dyn_cast<VPWidenPHIRecipe>(&Ingredient)) { | ||
auto *Phi = cast<PHINode>(VPPhi->getUnderlyingValue()); | ||
if (const auto *II = GetIntOrFpInductionDescriptor(Phi)) { | ||
VPValue *Start = Plan->getVPValueOrAddLiveIn(II->getStartValue()); | ||
VPValue *Step = | ||
vputils::getOrCreateVPValueForSCEVExpr(*Plan, II->getStep(), SE); | ||
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start, Step, *II); | ||
} else { | ||
Plan->addVPValue(Phi, VPPhi); | ||
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: now more appealing to swap and have an early continue. 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. Done thanks! |
||
const auto *II = GetIntOrFpInductionDescriptor(Phi); | ||
if (!II) | ||
continue; | ||
} | ||
|
||
VPValue *Start = Plan->getVPValueOrAddLiveIn(II->getStartValue()); | ||
VPValue *Step = | ||
vputils::getOrCreateVPValueForSCEVExpr(*Plan, II->getStep(), SE); | ||
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start, Step, *II); | ||
} else { | ||
assert(isa<VPInstruction>(&Ingredient) && | ||
"only VPInstructions expected here"); | ||
|
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.
Does it make more sense to move
VPlan
toVPRecipeBuilder
?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.
Forgot to mention, this has been split off & landed in 8578b6e, thanks!