[llvm-dev] InstCombine GEP

Nuno Lopes via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 10 10:58:09 PDT 2017


> On Thu, Aug 10, 2017 at 12:22 AM, Nema, Ashutosh via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> I’m not sure how transforming GEP offset to i8 type will help alias 
>> analysis & SROA for the mentioned test case.
>
> It should neither help nor hinder AA or SROA -- the two GEPs (the complex one and the simple one) are equivalent.  > Since memory isn't typed in LLVM, having the GEP in terms of %struct.ABC does not provide any extra information.

Memory is somewhat typed, since if you store something with a type and load the same location with a different type that's not valid (let's call it poison).

Also, BasicAA has the following rule, with constants c1 and c2, and arbitrary values x, y:
a[x][c1] no-alias a[y][c2] if:
the distance between c1 and c2 is sufficient to guarantee that the accesses will be disjoint due to ending up in different array slots.
For this rule it's important to know what's the size of each array element. This information is lost if GEPs are flattened.

But I agree that LLVM itself doesn't exploit types for AA extensively. For example, a pointer based in a struct field may alias another field of the same struct, even if at C/C++ level that's probably not allowed.

Nuno



More information about the llvm-dev mailing list