[llvm] [SROA] Extend tree-structured merge to handle init + RMW pattern (PR #194441)
Princeton Ferro via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 17:05:51 PDT 2026
================
@@ -2856,12 +2856,14 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
/// Attempts to rewrite a partition using tree-structured merge optimization.
///
- /// This function analyzes a partition to determine if it can be optimized
- /// using a tree-structured merge pattern, where multiple non-overlapping
- /// stores completely fill an alloca. And there is no load from the alloca in
- /// the middle of the stores. Such patterns can be optimized by eliminating
- /// the intermediate stores and directly constructing the final vector by
- /// using shufflevectors.
+ /// This function handles two patterns. Both produce an O(log n) tree of
+ /// shufflevectors in place of the linear expand+blend chain that SROA would
+ /// otherwise emit for each partial store.
+ ///
+ /// Pattern 1 (stores-only):
+ /// Multiple non-overlapping partial stores completely fill the alloca and
+ /// there is exactly one full-width load. The stores are tree-merged into
----------------
Prince781 wrote:
nit?: "and there is exactly one full-width load coming after the stores"
https://github.com/llvm/llvm-project/pull/194441
More information about the llvm-commits
mailing list