-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[VPlan] Cast to VPIRMetadata in getMemoryLocation (NFC) #169028
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
Conversation
This allows us to strip an unnecessary TypeSwitch.
|
@llvm/pr-subscribers-llvm-transforms Author: Ramkumar Ramachandra (artagnon) ChangesThis allows us to strip an unnecessary TypeSwitch. Full diff: https://github.com/llvm/llvm-project/pull/169028.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index 2536d61392ed1..cffc40960e47c 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -397,17 +397,14 @@ bool VPBlockUtils::isLatch(const VPBlockBase *VPB,
std::optional<MemoryLocation>
vputils::getMemoryLocation(const VPRecipeBase &R) {
- return TypeSwitch<const VPRecipeBase *, std::optional<MemoryLocation>>(&R)
- .Case<VPWidenMemoryRecipe, VPInterleaveBase, VPReplicateRecipe>(
- [](auto *S) {
- MemoryLocation Loc;
- // Populate noalias metadata from VPIRMetadata.
- if (MDNode *NoAliasMD = S->getMetadata(LLVMContext::MD_noalias))
- Loc.AATags.NoAlias = NoAliasMD;
- if (MDNode *AliasScopeMD =
- S->getMetadata(LLVMContext::MD_alias_scope))
- Loc.AATags.Scope = AliasScopeMD;
- return Loc;
- })
- .Default([](auto *) { return std::nullopt; });
+ auto *M = dyn_cast<VPIRMetadata>(&R);
+ if (!M)
+ return std::nullopt;
+ MemoryLocation Loc;
+ // Populate noalias metadata from VPIRMetadata.
+ if (MDNode *NoAliasMD = M->getMetadata(LLVMContext::MD_noalias))
+ Loc.AATags.NoAlias = NoAliasMD;
+ if (MDNode *AliasScopeMD = M->getMetadata(LLVMContext::MD_alias_scope))
+ Loc.AATags.Scope = AliasScopeMD;
+ return Loc;
}
|
|
@llvm/pr-subscribers-vectorizers Author: Ramkumar Ramachandra (artagnon) ChangesThis allows us to strip an unnecessary TypeSwitch. Full diff: https://github.com/llvm/llvm-project/pull/169028.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index 2536d61392ed1..cffc40960e47c 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -397,17 +397,14 @@ bool VPBlockUtils::isLatch(const VPBlockBase *VPB,
std::optional<MemoryLocation>
vputils::getMemoryLocation(const VPRecipeBase &R) {
- return TypeSwitch<const VPRecipeBase *, std::optional<MemoryLocation>>(&R)
- .Case<VPWidenMemoryRecipe, VPInterleaveBase, VPReplicateRecipe>(
- [](auto *S) {
- MemoryLocation Loc;
- // Populate noalias metadata from VPIRMetadata.
- if (MDNode *NoAliasMD = S->getMetadata(LLVMContext::MD_noalias))
- Loc.AATags.NoAlias = NoAliasMD;
- if (MDNode *AliasScopeMD =
- S->getMetadata(LLVMContext::MD_alias_scope))
- Loc.AATags.Scope = AliasScopeMD;
- return Loc;
- })
- .Default([](auto *) { return std::nullopt; });
+ auto *M = dyn_cast<VPIRMetadata>(&R);
+ if (!M)
+ return std::nullopt;
+ MemoryLocation Loc;
+ // Populate noalias metadata from VPIRMetadata.
+ if (MDNode *NoAliasMD = M->getMetadata(LLVMContext::MD_noalias))
+ Loc.AATags.NoAlias = NoAliasMD;
+ if (MDNode *AliasScopeMD = M->getMetadata(LLVMContext::MD_alias_scope))
+ Loc.AATags.Scope = AliasScopeMD;
+ return Loc;
}
|
🐧 Linux x64 Test Results
|
fhahn
left a comment
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.
LGTM, thanks.
For the titel, maybe clarify that this use dyn_cast to VPIRMetadata
This allows us to strip an unnecessary TypeSwitch.