[PATCH] D76194: [BasicAA] Use known lower bounds for index values for size based check.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 15 05:52:44 PDT 2020


fhahn created this revision.
fhahn added reviewers: sanjoy, hfinkel, reames, asbirlea.
Herald added subscribers: arphaman, hiraditya.
Herald added a project: LLVM.

Currently, BasicAA does not exploit information about value ranges of
indexes. For example, consider the 2 pointers %a = %base and
%b = %base + %stride below, assuming they are used to access 4 elements.

If we know that %stride >= 4, we know the accesses do not alias. If
%stride is a constant, BasicAA currently gets that. But if the >= 4
constraint is encoded using an assume, it misses the NoAlias.

This patch extends DecomposedGEP to include an additional MinOtherOffset
field, which tracks the constant offset similar to the existing
OtherOffset, which the difference that it also includes non-negative
lower bounds on the range of the index value. When checking if the
distance between 2 accesses exceeds the access size, we can use this
improved bound.

For now this is limited to using non-negative lower bounds for indices,
as this conveniently skips cases where we do not have a useful lower
bound (because it is not constrained). We potential miss out in cases
where the lower bound is constrained but negative, but that can be
exploited in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76194

Files:
  llvm/include/llvm/Analysis/BasicAliasAnalysis.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/test/Analysis/BasicAA/assume-index-positive.ll
  llvm/test/Analysis/BasicAA/bug.23626.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76194.250415.patch
Type: text/x-patch
Size: 10294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200315/1a64fa97/attachment.bin>


More information about the llvm-commits mailing list