From e7bab24414df44876cc5f896d16f65be0ff83775 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra 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 vputils::getMemoryLocation(const VPRecipeBase &R) { - return TypeSwitch>(&R) - .Case( - [](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(&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; }