[LLVMdev] Dependence Analysis [was: Flow-Sensitive AA]

Eli Friedman eli.friedman at gmail.com
Sun Aug 24 15:28:12 PDT 2008


On Sun, Aug 24, 2008 at 2:46 PM, Wojciech Matyjewicz
<wmatyjewicz at fastmail.fm> wrote:
>> I asked myself the same question. Without mod, how do you ensure that for instance the expression 2*i+255 was not actually 2*i-1 ?
>
> I think it is not possible in general, but I believe it is possible in
> case of affine expressions used as GEP indices.
>
> I assume, GEP indices (except indexing into struct) are interpreted as
> signed integers. It isn't explicitly stated in the LangRef, but the code
> seems to treat them this way. Am I correct?

Well, if you assume it's impossible to allocate more than 2GB on a
32-bit platform, you can assume GEP operands are signed.  You do have
to be careful, though; it's not inconceivable that someone could
allocate more than 2GB on a 32-bit platform, and you still have to
watch out for the operands overflowing.  That said, GEP overflow is
undefined, and that might be good enough for some purposes.

Also, here's a trick that could be useful for calculations that are
sensitive to overflow: if a loop has only a single possible exit
controlled by an index variable, and it doesn't use any
synchronization primitives, you can assume the loop isn't infinite for
dependence analysis purposes.  If the loop does end up being infinite,
the results aren't visible outside of the loop, so it doesn't matter
if results aren't accurate.

-Eli



More information about the llvm-dev mailing list