[llvm] [MergedLoadStore] Preserve common metadata when sinking stores. (PR #116382)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 15 05:25:35 PST 2024
================
@@ -255,7 +255,15 @@ void MergedLoadStoreMotion::sinkStoresAndGEPs(BasicBlock *BB, StoreInst *S0,
BasicBlock::iterator InsertPt = BB->getFirstInsertionPt();
// Intersect optional metadata.
S0->andIRFlags(S1);
- S0->dropUnknownNonDebugMetadata();
+
+ // Keep metadata present on both instructions.
+ SmallVector<std::pair<unsigned, MDNode *>> MDs;
+ S0->getAllMetadataOtherThanDebugLoc(MDs);
+ SmallVector<unsigned> CommonMDs;
+ for (const auto &[Kind, MD] : MDs)
+ if (S1->getMetadata(Kind) == MD)
+ CommonMDs.push_back(Kind);
+ S0->dropUnknownNonDebugMetadata(CommonMDs);
----------------
nikic wrote:
Shouldn't we be using combineMetadataForCSE here with DoesKMove=true?
https://github.com/llvm/llvm-project/pull/116382
More information about the llvm-commits
mailing list