[llvm] [LSROA] Add logical SROA pass (PR #192058)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 05:44:50 PDT 2026


================
@@ -15318,6 +15318,14 @@ If the source pointer is poison, the instruction returns poison.
 The resulting pointer belongs to the same address space as ``source``.
 This instruction does not dereference the pointer.
 
+Chaining indices in a single ``llvm.structured.gep`` instruction or spliting
+is sequentialy over multiple has exactly the same behavior. As such, two
+``llvm.structured.gep`` instruction can be merged if the second one base
+pointer is the result of the first by appending the indices of the second to
+the first.
+Conversely, a single structured GEP instruction can be split in to by
+splitting the indices sequence over multiple instructions.
----------------
Keenuts wrote:

Gave this a bit of a thought, and I don't think we should say it's illegal: I think this optimization should instead validate all pointer users (and indirect) are fine and that the pointer is not escaping.

This means we should only split alloca if we see the whole load/store chain, and that we don't pass the pointer to a call.
I'll add tests for such cases, and modify the pass.

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


More information about the llvm-commits mailing list