[clang] [llvm] [IR] Change representation of getelementptr inrange (PR #84341)

Nicolai Hähnle via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 19:08:01 PST 2024


nhaehnle wrote:

Have you thought about the implications for dynamic (non-constant) indices? Stuff like
```
  %gep = getelementptr [50 x {i32, [10 x i32]}], ptr %base, i32 0, i32 %outer_idx, i32 1, i32 %inner_idx
```
The current representation allows an `inrange` on the second-to-last index which to my understanding restricts the range to the `[10 x i32]` into which `%gep` falls structurally.

It seems like neither proposed representation is able to capture that in a single `ptradd` (it could be captured with a sequence of two `ptradd`s, but that's an awkward tradeoff).

The first proposed representation at least allows handling the case when there is only a single dynamic index, and the `inrange` is to the right of it.

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


More information about the cfe-commits mailing list