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

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 08:30:00 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:

To me this paragraph is a no-op definition-wise, but make something that is inferred explicit:

In the current definition:
```
The first index determines which element/field of ``basetype`` is selected,
computes the pointer to access this element/field assuming ``source`` points
to the start of ``basetype``.
This pointer becomes the new ``source``, the current type the new
``basetype``, and the next indices is consumed until a scalar type is
reached or all indices are consumed.
```

IMO this already defines the iterative nature of the indices, and already validates a structured GEP can be split/merged.
This paragraph is more or less explicitly telling the same thing.
@nikic what was the thing you were worried about?

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


More information about the llvm-commits mailing list