-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Manage noalias/alias_scope metadata in VPlan. #136450
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -65,6 +65,7 @@ class VPReplicateRecipe; | |||||||
class VPlanSlp; | ||||||||
class Value; | ||||||||
class LoopVectorizationCostModel; | ||||||||
class LoopVersioning; | ||||||||
|
||||||||
struct VPCostContext; | ||||||||
|
||||||||
|
@@ -1236,11 +1237,20 @@ struct VPIRPhi : public VPIRInstruction { | |||||||
class VPIRMetadata { | ||||||||
SmallVector<std::pair<unsigned, MDNode *>> Metadata; | ||||||||
|
||||||||
protected: | ||||||||
public: | ||||||||
VPIRMetadata() {} | ||||||||
|
||||||||
/// Adds metatadata that can be preserved from the original instruction | ||||||||
/// \p I. | ||||||||
VPIRMetadata(Instruction &I) { getMetadataToPropagate(&I, Metadata); } | ||||||||
|
||||||||
public: | ||||||||
/// Adds metatadata that can be preserved from the original instruction | ||||||||
/// \p I and noalias metadata guaranteed by runtime checks using \p LVer. | ||||||||
VPIRMetadata(Instruction &I, LoopVersioning *LVer); | ||||||||
|
||||||||
/// Copy constructor for cloning. | ||||||||
VPIRMetadata(const VPIRMetadata &Other) : Metadata(Other.Metadata) {} | ||||||||
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.
Suggested change
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 thanks |
||||||||
|
||||||||
/// Add all metadata to \p I. | ||||||||
void applyMetadata(Instruction &I) const; | ||||||||
}; | ||||||||
|
@@ -2511,7 +2521,7 @@ class VPReductionEVLRecipe : public VPReductionRecipe { | |||||||
/// copies of the original scalar type, one per lane, instead of producing a | ||||||||
/// single copy of widened type for all lanes. If the instruction is known to be | ||||||||
/// uniform only one copy, per lane zero, will be generated. | ||||||||
class VPReplicateRecipe : public VPRecipeWithIRFlags { | ||||||||
class VPReplicateRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { | ||||||||
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. Should replication of loads/stores have a separate recipe, if only they hold metadata? Would that separation be helpful in general. 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. It would be good to break up the recipes, to remove the reliance on the underlying IR instruction. Other case to split off would probably be calls, but probably best done separately, as this will require quite a bit of work (currently it is all based on cloning the existing IR instruction). VPReplicateRecipes other than loads should also have metadata; currently they use all metadata from the original instruction (due to cloning); this may be incorrect, as only certain IR metadata should be preserved (like widen-recipes, which only preserve a subset of the original metadata), again probably best to fix separately. 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. Commit message should mention that this patch also affects how ReplicateRecipe handle metadata. Does it fix the possibly incorrect behavior mentioned above? A test may be helpful. 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. It doesn't fix it yet, it doesn't change the behavior as the exsting cloning of instructions will preserve all metadata, the noalias MD is now added by VPIRMetadata. |
||||||||
/// Indicator if only a single replica per lane is needed. | ||||||||
bool IsUniform; | ||||||||
|
||||||||
|
@@ -2520,9 +2530,10 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags { | |||||||
|
||||||||
public: | ||||||||
VPReplicateRecipe(Instruction *I, ArrayRef<VPValue *> Operands, | ||||||||
bool IsUniform, VPValue *Mask = nullptr) | ||||||||
bool IsUniform, VPValue *Mask = nullptr, | ||||||||
VPIRMetadata Metadata = {}) | ||||||||
: VPRecipeWithIRFlags(VPDef::VPReplicateSC, Operands, *I), | ||||||||
IsUniform(IsUniform), IsPredicated(Mask) { | ||||||||
VPIRMetadata(Metadata), IsUniform(IsUniform), IsPredicated(Mask) { | ||||||||
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. Should this be
Suggested change
to propagate 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. Updated to use |
||||||||
if (Mask) | ||||||||
addOperand(Mask); | ||||||||
} | ||||||||
|
@@ -2532,7 +2543,7 @@ class VPReplicateRecipe : public VPRecipeWithIRFlags { | |||||||
VPReplicateRecipe *clone() override { | ||||||||
auto *Copy = | ||||||||
new VPReplicateRecipe(getUnderlyingInstr(), operands(), IsUniform, | ||||||||
isPredicated() ? getMask() : nullptr); | ||||||||
isPredicated() ? getMask() : nullptr, *this); | ||||||||
Copy->transferFlags(*this); | ||||||||
return Copy; | ||||||||
} | ||||||||
|
@@ -2692,8 +2703,9 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPIRMetadata { | |||||||
|
||||||||
VPWidenMemoryRecipe(const char unsigned SC, Instruction &I, | ||||||||
std::initializer_list<VPValue *> Operands, | ||||||||
bool Consecutive, bool Reverse, DebugLoc DL) | ||||||||
: VPRecipeBase(SC, Operands, DL), VPIRMetadata(I), Ingredient(I), | ||||||||
bool Consecutive, bool Reverse, | ||||||||
const VPIRMetadata &Metadata, DebugLoc DL) | ||||||||
: VPRecipeBase(SC, Operands, DL), VPIRMetadata(Metadata), Ingredient(I), | ||||||||
Consecutive(Consecutive), Reverse(Reverse) { | ||||||||
assert((Consecutive || !Reverse) && "Reverse implies consecutive"); | ||||||||
} | ||||||||
|
@@ -2751,16 +2763,17 @@ class VPWidenMemoryRecipe : public VPRecipeBase, public VPIRMetadata { | |||||||
/// optional mask. | ||||||||
struct VPWidenLoadRecipe final : public VPWidenMemoryRecipe, public VPValue { | ||||||||
VPWidenLoadRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask, | ||||||||
bool Consecutive, bool Reverse, DebugLoc DL) | ||||||||
bool Consecutive, bool Reverse, | ||||||||
const VPIRMetadata &Metadata, DebugLoc DL) | ||||||||
: VPWidenMemoryRecipe(VPDef::VPWidenLoadSC, Load, {Addr}, Consecutive, | ||||||||
Reverse, DL), | ||||||||
Reverse, Metadata, DL), | ||||||||
VPValue(this, &Load) { | ||||||||
setMask(Mask); | ||||||||
} | ||||||||
|
||||||||
VPWidenLoadRecipe *clone() override { | ||||||||
return new VPWidenLoadRecipe(cast<LoadInst>(Ingredient), getAddr(), | ||||||||
getMask(), Consecutive, Reverse, | ||||||||
getMask(), Consecutive, Reverse, *this, | ||||||||
getDebugLoc()); | ||||||||
} | ||||||||
|
||||||||
|
@@ -2792,7 +2805,7 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue { | |||||||
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask) | ||||||||
: VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(), | ||||||||
{L.getAddr(), &EVL}, L.isConsecutive(), | ||||||||
L.isReverse(), L.getDebugLoc()), | ||||||||
L.isReverse(), L, L.getDebugLoc()), | ||||||||
VPValue(this, &getIngredient()) { | ||||||||
setMask(Mask); | ||||||||
} | ||||||||
|
@@ -2829,16 +2842,17 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPValue { | |||||||
/// to store to and an optional mask. | ||||||||
struct VPWidenStoreRecipe final : public VPWidenMemoryRecipe { | ||||||||
VPWidenStoreRecipe(StoreInst &Store, VPValue *Addr, VPValue *StoredVal, | ||||||||
VPValue *Mask, bool Consecutive, bool Reverse, DebugLoc DL) | ||||||||
VPValue *Mask, bool Consecutive, bool Reverse, | ||||||||
const VPIRMetadata &Metadata, DebugLoc DL) | ||||||||
: VPWidenMemoryRecipe(VPDef::VPWidenStoreSC, Store, {Addr, StoredVal}, | ||||||||
Consecutive, Reverse, DL) { | ||||||||
Consecutive, Reverse, Metadata, DL) { | ||||||||
setMask(Mask); | ||||||||
} | ||||||||
|
||||||||
VPWidenStoreRecipe *clone() override { | ||||||||
return new VPWidenStoreRecipe(cast<StoreInst>(Ingredient), getAddr(), | ||||||||
getStoredValue(), getMask(), Consecutive, | ||||||||
Reverse, getDebugLoc()); | ||||||||
Reverse, *this, getDebugLoc()); | ||||||||
} | ||||||||
|
||||||||
VP_CLASSOF_IMPL(VPDef::VPWidenStoreSC); | ||||||||
|
@@ -2872,7 +2886,8 @@ struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe { | |||||||
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask) | ||||||||
: VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(), | ||||||||
{S.getAddr(), S.getStoredValue(), &EVL}, | ||||||||
S.isConsecutive(), S.isReverse(), S.getDebugLoc()) { | ||||||||
S.isConsecutive(), S.isReverse(), S, | ||||||||
S.getDebugLoc()) { | ||||||||
setMask(Mask); | ||||||||
} | ||||||||
|
||||||||
|
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 the removal of AC initialization related?
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.
Added back, dropped accidentially thanks