[llvm-dev] InstCombine GEP

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 13 22:24:14 PDT 2017


Hi,

On Thu, Aug 10, 2017 at 10:58 AM, Nuno Lopes via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>> 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).

That may be true in C++, but I'm not sure if we want that to be true
in LLVM IR.  We would not be able to inline memcpy's if that were
true, for one thing (e.g. https://godbolt.org/g/2VVJHU).  Unless
you're talking about TBAA metadata?

> 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.

Do you mean to say that in LLVM IR we will conclude ptr0 and ptr1 don't alias:

  int a[4][4];
  ptr0 = &a[x][3];
  ptr1 = &a[y][7];

If so, that doesn't match my understanding -- I was under the
impression that in LLVM IR x = 2, y = 1 will give us must-alias
between ptr0 and ptr1.

-- Sanjoy

>
> 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
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list