[llvm] [VectorCombine] Preserve scoped alias metadata (PR #153714)

Kyle Wang via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 15 14:18:45 PDT 2025


================
@@ -1831,6 +1835,14 @@ bool VectorCombine::scalarizeLoadExtract(Instruction &I) {
         LI->getAlign(), VecTy->getElementType(), Idx, *DL);
     NewLoad->setAlignment(ScalarOpAlignment);
 
+    if (MDNode *aliasScope = LI->getMetadata(aliasScopeKind)) {
+      NewLoad->setMetadata(aliasScopeKind, aliasScope);
+    }
+
+    if (MDNode *noAlias = LI->getMetadata(noAliasKind)) {
+      NewLoad->setMetadata(noAliasKind, noAlias);
+    }
----------------
knwng wrote:

Hi @nikic, thank you for the advice. I know it's a more thoughtful solution. But I'm not familiar with AA in LLVM. Can you guide me on how to use `adjustForAccess()`, like how to correctly calculate offset and type? Thanks!

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


More information about the llvm-commits mailing list