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

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 5 23:03:15 PST 2021


courbet added a comment.

In D114988#3172161 <https://reviews.llvm.org/D114988#3172161>, @nlopes wrote:

> 



> In the past, Johannes proposed using range information for the variables in GEP (using the assumptions machinery already available). That could work, but we need to make sure it doesn't block optimizations. We don't LLVM to trigger UB if an array index is OOB; we just need it to turn poison.

Note that since D109746 <https://reviews.llvm.org/D109746>,  BasicAA already uses ranges information to derive `NoAlias`. This is an example where the range information can help independently of proving UB. For now this only works when the compiler can otherwise prove the range, e.g. for

  struct Histogram {
    int buckets[4];
    int count;
  
    void f(unsigned i) {
      ++buckets[i & 3];
      ++count;
      // buckets[i&3] and count are noalias.
    }
  };

When clang starts emitting range information (in any form recognizable by `ValueTracking`, I don't have a strong opinion on which for is best), we can start having `buckets[i & 3]` and `count` be `NoAlias` more generally.


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