[PATCH] D114988: [IR] `GetElementPtrInst`: per-index `inrange` support

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 2 12:58:53 PST 2021


nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

While I support the general goal of exposing GEP offset restrictions to IR, I am quite strongly opposed to the implementation approach of extending `inrange`. The core issue is that this is strongly tied to LLVM struct types and structural GEP indexing. This will be a blow to opaque pointer usefulness and future offset canonicalization for GEPs.

I think the correct approach to `inrange`-like information is to restrict the range of GEP indices without relying on the underlying structure type. Think `inrange(0, 4) i32 %x` for `%x` between 0 and 4. This naturally integrates in purely offset-based alias analysis, and can be more generally preserved under transformation. For example, if you have `gep %base, inrange (%x + 1)`, if this is transformed into `gep (gep %base, 1), %x` there is no way to preserve `inrange` information under the current proposal, while a proper offset-based approach could easily retain information under simple transformations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114988/new/

https://reviews.llvm.org/D114988



More information about the llvm-commits mailing list