[llvm] [AggressiveInstCombine] Merge consecutive loads of mixed sizes (PR #129263)

Zhenyang Xu via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 1 01:39:37 PST 2025


================
@@ -675,10 +675,10 @@ static bool foldLoadsRecursive(Value *V, LoadOps &LOps, const DataLayout &DL,
       Load2Ptr->stripAndAccumulateConstantOffsets(DL, Offset2,
                                                   /* AllowNonInbounds */ true);
 
-  // Verify if both loads have same base pointers and load sizes are same.
+  // Verify if both loads have same base pointers
   uint64_t LoadSize1 = LI1->getType()->getPrimitiveSizeInBits();
   uint64_t LoadSize2 = LI2->getType()->getPrimitiveSizeInBits();
-  if (Load1Ptr != Load2Ptr || LoadSize1 != LoadSize2)
+  if (Load1Ptr != Load2Ptr)
     return false;
 
   // Support Loadsizes greater or equal to 8bits and only power of 2.
----------------
Cancelll wrote:

In that case, I think we need to check the sum of the sizes of the consecutive loads? Otherwise, for example, i8, i16, i8 cannot be merged because the intermediate i24 will fail the check.

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


More information about the llvm-commits mailing list