[BasicAA] Make range check more precise
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 25 Oct 2021 16:47:51 +0000 (18:47 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 27 Oct 2021 10:40:58 +0000 (12:40 +0200)
commit9bc7e543b4ef5eef2be2325204db20073fc18e36
tree07eae588b91008192875657627023a5834f54b37
parentdb848fbf671d99256b2840e19ed3b0b349069e48
[BasicAA] Make range check more precise

Make the range check more precise by calculating the range of
potentially accessed bytes for both accesses and checking whether
their intersection is empty. In that case there can be no overlap
between the accesses and the result is NoAlias.

This is more powerful than the previous approach, because it can
deal with sign-wrapped ranges. In the test case the original range
is [-1, INT_MAX] but becomes [0, INT_MIN] after applying the offset.
This is a wrapping range, so getSignedMin/getSignedMax will treat
it as a full range. However, the range excludes the elements
[INT_MIN+1, -1], which is enough to prove NoAlias with an access
at offset -1.

Differential Revision: https://reviews.llvm.org/D112486
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/range.ll