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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 1 01:22:31 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.
----------------
dtcxzyw wrote:

Wait, I see `load i56` instructions exist in some rust applications. Can we further relax the constraints to allow non-pow2 loads? It would make sense to check `ispow2(loadsize1 + loadsize2)`.


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


More information about the llvm-commits mailing list