[llvm] [SROA] Pre-split overlapping move slices within a partition (PR #210061)

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 08:52:28 PDT 2026


================
@@ -4923,7 +4971,37 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
       assert(Offsets.Splits.empty() &&
              "Should not have splits the first time we see an instruction!");
       Offsets.S = &S;
-      Offsets.Splits.push_back(P.endOffset() - S.beginOffset());
+      if (CopyOverlap) {
+        // S is being moved to CopyOverlap, which overlaps with S, so we split S
+        // into three parts:
+        //  * Initially outside the overlap and copied into the overlap.
+        //  * Either initially inside the overlap and remains inside it after
+        //    the copy, or initially outside and remains outside, depending on
+        //    if the overlap or non-overlap area is larger, and which will be
+        //    empty if they are equal.
+        //  * Initially inside the overlap and copied outside the overlap.
+        // This should result in the first and last parts being promoted to
+        // scalars, which may result in the middle part now being an overlapping
----------------
john-brawn-arm wrote:

It was written this way basically just because it was easier, but yes just doing all of the splitting in one is better. I've adjusted it to do this.

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


More information about the llvm-commits mailing list