[llvm] [InstCombine] Propagate invariant.load metadata across unpacked loads (PR #152186)

Vedant Paranjape via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 13 15:43:36 PDT 2025


================
@@ -762,8 +771,13 @@ static Instruction *unpackLoadToAggregate(InstCombinerImpl &IC, LoadInst &LI) {
           ST->getElementType(i), Ptr,
           commonAlignment(Align, SL->getElementOffset(i).getKnownMinValue()),
           Name + ".unpack");
+      // Adjust AA metadata to new offset and size.
+      AAMDNodes adjustedAANodes = LI.getAAMetadata().adjustForAccess(
+          SL->getElementOffset(i),
+          SL->getElementOffset(i).getKnownMinValue());
       // Propagate AA metadata. It'll still be valid on the narrowed load.
-      L->setAAMetadata(LI.getAAMetadata());
+      L->setAAMetadata(adjustedAANodes);
+      copyInvariantLoadMetadata(LI, L);
----------------
VedantParanjape wrote:

@dtcxzyw I have fixed these issues, could you please give a lgtm?

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


More information about the llvm-commits mailing list