[llvm] [VPlan] Directly retrieve metadata in getMemoryLocation (NFC) (PR #169028)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 03:17:45 PST 2025
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/169028
This allows us to strip an unnecessary TypeSwitch.
>From e7bab24414df44876cc5f896d16f65be0ff83775 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Fri, 21 Nov 2025 11:15:12 +0000
Subject: [PATCH] [VPlan] Directly retrieve metadata in getMemoryLocation (NFC)
This allows us to strip an unnecessary TypeSwitch.
---
llvm/lib/Transforms/Vectorize/VPlanUtils.cpp | 23 +++++++++-----------
1 file changed, 10 insertions(+), 13 deletions(-)
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;
}
More information about the llvm-commits
mailing list