[llvm] [AggressiveInstCombine] Implement store merge optimization (PR #147540)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 09:09:38 PDT 2025


================
@@ -842,6 +842,141 @@ static bool foldConsecutiveLoads(Instruction &I, const DataLayout &DL,
   return true;
 }
 
+/// ValWidth bits starting at ValOffset of Val stored at PtrBase+PtrOffset.
+struct PartStore {
+  Value *PtrBase;
+  APInt PtrOffset;
+  Value *Val;
+  uint64_t ValOffset;
+  uint64_t ValWidth;
+  StoreInst *Store;
+
+  bool isCompatibleWith(const PartStore &Other) const {
+    return PtrBase == Other.PtrBase && Val == Other.Val;
----------------
dtcxzyw wrote:

TODO: We can merge two stores with different constant value operands.
See https://github.com/dtcxzyw/llvm-opt-benchmark/pull/2560/files#r2192918824

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


More information about the llvm-commits mailing list