[llvm] [VPlan] Directly retrieve metadata in getMemoryLocation (NFC) (PR #169028)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 21 03:18:18 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Ramkumar Ramachandra (artagnon)

<details>
<summary>Changes</summary>

This allows us to strip an unnecessary TypeSwitch.

---
Full diff: https://github.com/llvm/llvm-project/pull/169028.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/VPlanUtils.cpp (+10-13) 


``````````diff
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;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/169028


More information about the llvm-commits mailing list