[llvm] Patch tryCanonicalizeStructToVector to handle split slice tails (PR #201434)

Yaxun Liu via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 07:07:14 PDT 2026


================
@@ -67,3 +67,41 @@ merge:
   call void @llvm.memcpy.p0.p0.i64(ptr align 8 %dst, ptr align 8 %sel, i64 16, i1 false)
   ret void
 }
+
+; SROA sees these slices:
+;   [0,8)   load ptr
+;   [0,32)  store i256, splittable
+;   [8,16)  load i64, splittable
+;   [16,32) memcpy source, splittable
+;
+; These form three partitions:
+;   [0,8)   contains the ptr load and the store i256 slice that starts at 0
+;   [8,16)  contains the i64 load, plus the store i256 split tail
+;   [16,32) contains the memcpy source, plus the store i256 split tail
+;
+; The [16,32) subpartition has type { i64, i64 }, and the only slice that
+; starts in the partition is a memcpy. However, the whole-alloca i256 store is a
+; split tail overlapping the subpartition, so it must block struct-to-vector
+; fallback canonicalization.
+
+; CHECK-LABEL: define void @test_split_tail_store_blocks_subpartition_type(
----------------
yxsamliu wrote:

This catches the intended bad transformation, but it is a bit broad. Could we also check for the expected remaining memory shape here, so the test documents what form we want after rejecting the `<2 x i64>` fallback?

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


More information about the llvm-commits mailing list