[llvm] [VectorUtils] Add helper to get list of metadata to propagate (NFC). (PR #135003)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 07:47:20 PDT 2025
================
@@ -984,19 +984,38 @@ MDNode *llvm::intersectAccessGroups(const Instruction *Inst1,
return MDNode::get(Ctx, Intersection);
}
+/// Add metadata from \p Inst to \p Metadata, if it can be preserved after
+/// vectorization.
+static void getMetadataToPropagate(
+ Instruction *Inst,
+ SmallVectorImpl<std::pair<unsigned, MDNode *>> &Metadata) {
+ Inst->getAllMetadataOtherThanDebugLoc(Metadata);
+ unsigned SupportedIDs[] = {
+ LLVMContext::MD_tbaa, LLVMContext::MD_alias_scope,
+ LLVMContext::MD_noalias, LLVMContext::MD_fpmath,
+ LLVMContext::MD_nontemporal, LLVMContext::MD_invariant_load,
+ LLVMContext::MD_access_group, LLVMContext::MD_mmra};
+
+ // Remove any unsupported metadata kinds from Metadata.
+ for (unsigned Idx = 0; Idx != Metadata.size();) {
+ if (is_contained(SupportedIDs, Metadata[Idx].first))
+ Idx++;
+ else {
----------------
alexey-bataev wrote:
```
if (is_contained(SupportedIDs, Metadata[Idx].first)) {
Idx++;
} else {
```
https://github.com/llvm/llvm-project/pull/135003
More information about the llvm-commits
mailing list