[PATCH] D20665: Claim NoAlias if two GEPs index different fields of the same struct

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 19:27:35 PDT 2016


On Wed, Jun 1, 2016 at 7:03 PM, Daniel Berlin via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> and the obvious modification still gives right answers (ie using x->a):
>
>   %5 = getelementptr inbounds %struct.A, %struct.A* %x, i32 0, i32 0
>   %6 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i32 0, i32 0
>   %7 = getelementptr inbounds i8, i8* %6, i64 %4
>   %8 = load i8, i8* %7, align 1
>   %9 = zext i8 %8 to i32
>   %10 = getelementptr inbounds %struct.A, %struct.A* %x, i32 0, i32 1
>
>
> %5 and %10 do *not* alias.
> The code says nothing about %10 and %6 or %7

What about something like:
  %a = getelementptr inbounds {[2 x i8], [2 x i8]}, {[2 x i8], [2 x i8]}*
%p, i32 0, i32 0, i32 1
  %b = getelementptr inbounds {[2 x i8], [2 x i8]}, {[2 x i8], [2 x i8]}*
%p, i32 0, i32 1, i32 -1
?

I think that's legal?  There was a similar discussion around r228498.

-Ahmed

> On Wed, Jun 1, 2016 at 7:01 PM, Daniel Berlin <dberlin at dberlin.org> wrote:
>>
>> Errr, this is not two GEPS of a struct type base pointer with the same
>> type, with a minimum of two operands, etc.
>>
>> It's
>>   %6 = getelementptr inbounds i8, i8* %5, i64 %4
>>    %9 = getelementptr inbounds %struct.A, %struct.A* %x, i32 0, i32 1
>>
>> This code will do nothing with this.
>>
>> Want to try again?
>> :)
>>
>>
>> On Wed, Jun 1, 2016 at 5:49 PM, Eli Friedman <eli.friedman at gmail.com>
>> wrote:
>>>
>>> eli.friedman added a comment.
>>>
>>> Example:
>>>
>>>   struct A {
>>>     unsigned char a[10];
>>>     unsigned char b;
>>>   };
>>>   void f(A* x) {
>>>     for (unsigned i = 0; i < 11; ++i)
>>>       x->b += ((unsigned char*)x)[i];
>>>   }
>>>
>>>
>>> Repository:
>>>   rL LLVM
>>>
>>> http://reviews.llvm.org/D20665
>>>
>>>
>>>
>>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160601/f54be93b/attachment.html>


More information about the llvm-commits mailing list