Skip to content

Commit b98f6a5

Browse files
authored
[VPlan] Cast to VPIRMetadata in getMemoryLocation (NFC) (#169028)
This allows us to strip an unnecessary TypeSwitch.
1 parent 31711c9 commit b98f6a5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,14 @@ bool VPBlockUtils::isLatch(const VPBlockBase *VPB,
397397

398398
std::optional<MemoryLocation>
399399
vputils::getMemoryLocation(const VPRecipeBase &R) {
400-
return TypeSwitch<const VPRecipeBase *, std::optional<MemoryLocation>>(&R)
401-
.Case<VPWidenMemoryRecipe, VPInterleaveBase, VPReplicateRecipe>(
402-
[](auto *S) {
403-
MemoryLocation Loc;
404-
// Populate noalias metadata from VPIRMetadata.
405-
if (MDNode *NoAliasMD = S->getMetadata(LLVMContext::MD_noalias))
406-
Loc.AATags.NoAlias = NoAliasMD;
407-
if (MDNode *AliasScopeMD =
408-
S->getMetadata(LLVMContext::MD_alias_scope))
409-
Loc.AATags.Scope = AliasScopeMD;
410-
return Loc;
411-
})
412-
.Default([](auto *) { return std::nullopt; });
400+
auto *M = dyn_cast<VPIRMetadata>(&R);
401+
if (!M)
402+
return std::nullopt;
403+
MemoryLocation Loc;
404+
// Populate noalias metadata from VPIRMetadata.
405+
if (MDNode *NoAliasMD = M->getMetadata(LLVMContext::MD_noalias))
406+
Loc.AATags.NoAlias = NoAliasMD;
407+
if (MDNode *AliasScopeMD = M->getMetadata(LLVMContext::MD_alias_scope))
408+
Loc.AATags.Scope = AliasScopeMD;
409+
return Loc;
413410
}

0 commit comments

Comments
 (0)